admin 管理员组文章数量: 1086019
I have used the below link to end a session.
/
In that i am able to redirect to the login page. But the user is not logging off. Just it is redirecting to that page. But it is not logging out. How can i log out the session in that case. Any help is appreciated.
I have used the below link to end a session.
http://pure-essence/2010/02/14/jquery-session-timeout-countdown/
In that i am able to redirect to the login page. But the user is not logging off. Just it is redirecting to that page. But it is not logging out. How can i log out the session in that case. Any help is appreciated.
Share Improve this question asked Dec 18, 2012 at 6:54 JonathanJonathan 1,6699 gold badges35 silver badges55 bronze badges 02 Answers
Reset to default 3Short Answer : Use FormsAuthentication.SignOut();
Long Answer
public ActionResult LogOff()
{
FormsAuthentication.SignOut();
return RedirectToAction("Login", "Account");
}
private ActionResult RedirectToLocal(string returnUrl)
{
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
Use [Authorize]
above the actions which you don't want the user to do after logging out. This you can do by adding this attribute above actions individually or marking the entire class with [Authorize]
so that all methods can now be only be accessed by authenticated users.
Hope this helps.
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
This should work in newer versions.
本文标签: javascripthow to log out the current user in aspnet mvcStack Overflow
版权声明:本文标题:javascript - how to log out the current user in asp.net mvc - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744050161a2524869.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论