62,041
社区成员
发帖
与我相关
我的任务
分享
//获取用户的角色
string userdata = txtID.Value;
// 创建身份验证票证
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, txtID.Value, DateTime.Now, DateTime.Now.AddMinutes(360), true, userdata);
string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
// 创建Cookie
HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
Response.Cookies.Remove("authCookie");
Response.Cookies.Add(authCookie);
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" name=".ASPXAUTH" />
</authentication>
<authenticationmode="Forms">
<forms loginUrl="Login.aspx" name=".ASPX"></forms>
<denyusers="?"></deny>
</authentication>