VerySource

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 910|回复: 4

用 Forms认证 ,老是 登录不进去了!! 救命啊!!

[复制链接]

2

主题

6

帖子

4.00

积分

新手上路

Rank: 1

积分
4.00
发表于 2020-1-5 13:50:01 | 显示全部楼层 |阅读模式
login.aspx.cs
里面是:
FormsAuthentication.SetAuthCookie(sUserId,Cookie.Checked);

其他页面有些 上面判断 登录了没有
if(HttpContext.Current.User.Identity.IsAuthenticated)
     {
      }

登录, 其他页面上的 if(HttpContext.Current.User.Identity.IsAuthenticated)
总是false 了,

怎么回事呢????   救命啊!!!!!



附:

<system.web>
       <hostingEnvironment idleTimeout="20" shutdownTimeout="30"/>
       <globalization   requestEncoding="gb2312"   responseEncoding="gb2312"   />
       <customErrors mode="Off" defaultRedirect="/Error.html" />
      
       <authentication mode="Forms">
     <forms loginUrl="/Login.aspx" defaultUrl="/Default.aspx"  name="UserCookie" protection="All" timeout="40" path="/" />
   </authentication>   
   
         
   </system.web>
回复

使用道具 举报

0

主题

21

帖子

12.00

积分

新手上路

Rank: 1

积分
12.00
发表于 2020-1-6 10:27:01 | 显示全部楼层
如果是使用forms认证,我没有看到你在web.config中添加的一些用户
还有,如果你有好多页面都要认证才可以访问,建议建一个文件夹,将保护的页面都放入,在web.config中在该文件夹设<deny user="?" /><allow user="*" />
这样你就不用在每个页面都加判断了
回复

使用道具 举报

0

主题

5

帖子

5.00

积分

新手上路

Rank: 1

积分
5.00
发表于 2020-1-6 10:36:01 | 显示全部楼层
just a example:

  if ((UserEmail.Text == "jchen@contoso.com") &&
            (UserPass.Text == "37Yj*99Ps"))
      {
          FormsAuthentication.RedirectFromLoginPage
             (UserEmail.Text, Persist.Checked);
      }
      else
      {
          Msg.Text = "Invalid credentials. Please try again.";
      }
  }
回复

使用道具 举报

2

主题

6

帖子

4.00

积分

新手上路

Rank: 1

积分
4.00
 楼主| 发表于 2020-1-6 17:54:01 | 显示全部楼层
用户 是 存在 数据库里面 的。。。。


if(HttpContext.Current.User.Identity.IsAuthenticated)
     {
      }

这句 是写在一个 按钮点击的时候的 ,
不是 页面限制的。。。。。


超郁闷!!

回复

使用道具 举报

2

主题

6

帖子

4.00

积分

新手上路

Rank: 1

积分
4.00
 楼主| 发表于 2020-2-12 11:45:01 | 显示全部楼层
求救 阿 !!!!大家 !!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

快速回复 返回顶部 返回列表