表单身份验证停止工作

时间:2016-02-07 09:09:14

标签: asp.net form-authentication

几年前,我一直在以前的项目中使用以下(Asp.net Forms身份验证)代码来授权用户。但为什么它不再起作用了?

此代码来自" safe"中的web.config。文件夹:

<configuration>
    <system.web>
            <authorization>                     
            <allow roles="User" /> 
            <deny users="*"/>       
        </authorization>
    </system.web>
</configuration>

这是login.aspx中的代码:

FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, TextBox1.Text, DateTime.Now, DateTime.Now.AddMinutes(6000), false, "User");
string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.Cookies.Add(authCookie);
Response.Redirect("LoggedOn/SafePage.aspx");

0 个答案:

没有答案
相关问题