安全验证

代码
//Todo
//FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked);

string userDatastring = Companies[i] + "|" + TitleatCompany[i];
HttpCookie authCookie
= FormsAuthentication.GetAuthCookie(UserName.Text, RememberMe.Checked);
FormsAuthenticationTicket ticket
= FormsAuthentication.Decrypt(authCookie.Value);
FormsAuthenticationTicket newTicket
= new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, userDatastring);
authCookie.Value
= FormsAuthentication.Encrypt(newTicket);
Response.Cookies.Add(authCookie);
string Url = FormsAuthentication.GetRedirectUrl(UserName.Text, RememberMe.Checked);
Response.Redirect(Url);

web.config

Code
原文地址:https://www.cnblogs.com/shineqiujuan/p/1351043.html