HttpContext.Current.Request.IsAuthenticated == true
用表单提交登录后,在一个类里判断是否登录成功IsAuthenticated 总是=假,为什么
以前不在表在中好用啊

解决方案 »

  1.   

    自定义类
    public class Class1
    {
        public string Mth()
        {
            return HttpContext.Current.Request.IsAuthenticated.ToString();
        }
    }
    页面调用
     protected void Button1_Click(object sender, EventArgs e)
        {
            Class1 c = new Class1();
            Response.Write(c.Mth());
        }
    返回值为true;
      

  2.   

                if (HttpContext.Current.User != null)
                {
                             
                    if (HttpContext.Current.Request.IsAuthenticated == true) //验证过的一般用户才能进行角色验证  
                    {
                        System.Web.Security.FormsIdentity fi = (System.Web.Security.FormsIdentity)HttpContext.Current.User.Identity;
                        System.Web.Security.FormsAuthenticationTicket ticket = fi.Ticket; //取得身份验证票  
                 }
                    return "";
                }
                else
                    return "";还是不行啊
      

  3.   

    Form表单的验证。具体的可以看看网上的资料。cnbologs上有你可以去看看
      

  4.   

    webconfig裡是不是沒有設置Form驗證啊
      

  5.   


    <!--验证方式及设置-->
        <authentication mode="Forms">
          <forms loginUrl="LoginDl.aspx" name=".yinyuebbCoName"></forms>
        </authentication>    <authorization>
          <allow users="*"/>
        </authorization>
    这样设置的