下列的
this
回答StackOverflow,Microsoft建议执行以下操作:
-
把饼干弄干净。
-
将Response.Status属性设置为401。
-
调用将隐式重定向的response.end方法
转到登录页。
我在我的
global.asax
文件,(我已向用户表中添加了一个名为
isLogin
我在登录和注销页面中将其设置为true和false…)
void Application_PostAuthenticateRequest(object sender, EventArgs e)
{
IPrincipal p = HttpContext.Current.User;
if (p.Identity.IsAuthenticated)
{
var userName = p.Identity.Name;
HttpCookie authenticationCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
if (SecurityUtilities.CheckUserLoggedIn(userName) == false)
{
FormsAuthentication.SignOut();
Response.StatusCode = 401;
Response.End();
}
}
}
我想知道我做的这些都对吗?这个密码怎么办?
if (SecurityUtilities.CheckUserLoggedIn(userName) == false)
{
FormsAuthentication.SignOut();
Response.Redirect(FormsAuthentication.LoginUrl);
}