我在一个web应用程序使用成员资格提供来实现认证和用户/应用的部分角色的访问工作。ASP.NET LoginStatus:注销不工作
我用我的母版页或注销链接LoginStatus
控制,但它的测试我发现,注销不起作用。如果我再次尝试访问我的应用程序的任何页面(后洛出)的页面显示...
我想这个问题取决于不会自动清除存储在用户会话数据。那就对了?
因此,这是实现注销,明确会议的corect方式?
注意 我不落实的LoginStatus
控制的任何事件。我正在使用表单身份验证。在我的登录页面,我使用此代码:
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // Ticket version
this.txtUser.Text, // Username associated with ticket
DateTime.Now, // Date/time issued
DateTime.Now.AddMinutes(30), // Date/time to expire
true, // "true" for a persistent user cookie
ruolo, // User-data, in this case the roles
FormsAuthentication.FormsCookiePath);
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName,
hash);
if (ticket.IsPersistent) { cookie.Expires = ticket.Expiration; }
Response.Cookies.Add(cookie);
在我的web.configsystem.web
部分:
<authentication mode="Forms">
<forms name=".ASPXAUTH" loginUrl="login.aspx" protection="All" path="/" domain="keyforup.it"/>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
我有这样的事情之前,我发现是问题了'SessionID'保持因无效的IIS设置更改,请确保您打印出'SessionID'页面,以确保其不会改变。 – Qpirate 2013-02-27 09:09:08
“如果我尝试再次访问我的应用程序的任何页面(后洛出)的页面显示” - 你有在web.config中,以防止页面的任何东西显示给未授权的用户 - 例如拒绝用户=“?”在web.config中 – Joe 2013-02-27 09:33:31
的System.Web程序/授权部@Joe是的......我编辑我的问题 – davioooh 2013-02-27 09:44:34