FormsAuthentication.SignOut 在 firefox 3 (asp.net) 上不起作用
我在登录页面中使用此代码。 这工作很好。
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // Ticket version
eUserName.Text,
DateTime.Now,
DateTime.Now.AddMinutes(30),
true,
"administrator",
FormsAuthentication.FormsCookiePath);
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName,
hash);
// Set the cookie's expiration time to the tickets expiration time
if (ticket.IsPersistent) cookie.Expires = ticket.Expiration;
// Add the cookie to the list for outgoing response
Response.Cookies.Add(cookie);
Response.Redirect("Default.aspx");
但是当我使用 FormsAuthentication.SignOut 或 asp:LoginStatus 控件注销时,这不会注销。 这似乎已登录。 当我在 Internet Explorer 8 上测试时,成功注销。
火狐怎么了? 我该如何解决这个问题?
感谢
ebattulga
I'm using this code in login page. This is work fine.
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // Ticket version
eUserName.Text,
DateTime.Now,
DateTime.Now.AddMinutes(30),
true,
"administrator",
FormsAuthentication.FormsCookiePath);
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName,
hash);
// Set the cookie's expiration time to the tickets expiration time
if (ticket.IsPersistent) cookie.Expires = ticket.Expiration;
// Add the cookie to the list for outgoing response
Response.Cookies.Add(cookie);
Response.Redirect("Default.aspx");
But when i logout using FormsAuthentication.SignOut or asp:LoginStatus control this is don't logout. this seems logged on. When i testing on the internet explorer 8, this successfully logout.
What happing on the firefox?
How can i do fix this problem?
Thanks
ebattulga
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
FireFox 和 FormsAuthentication 的问题在于 FireFox 似乎不会删除注销时的身份验证 cookie。 您可以尝试 3 件事:
1) 调用 SignOut 方法后,清除 cookie,如下所示 =>
Response.cookies.clear()
2) 尝试在 SignOut 调用之前调用
Session.abandon
3)您还可以尝试以下方法:
Response.Expires = 0, Response.Cache.SetNoStore(), Response.AppendHeader("Pragma", "no-cache")
希望这些有所帮助!
The problem with FireFox and FormsAuthentication is that FireFox doens't seem to delete the auth cookie on SignOut. 3 things you can try:
1) After calling the SignOut method, clear the cookies like this =>
Response.cookies.clear()
2) Try calling
Session.abandon
before your SignOut call3) You can also try the following:
Response.Expires = 0, Response.Cache.SetNoStore(), Response.AppendHeader("Pragma", "no-cache")
Hope those help!