从MVC注销 [英] Logout from MVC

查看:159
本文介绍了从MVC注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC应用程序,我不得不退出。要我创建TE主网页上的链接申请注销

I have a MVC application and I have to logout. To logout from the application I have created a link on te master page

[ <a id="A2" name="lnkLogout" href="http://localhost:1234/Home/LogOut" >Logout</a> ]

和创建控制器页LoutOut动作

and created the LoutOut action in the controller page

 public ActionResult LogOut()
        {
            Session.Clear();
            Session.Abandon();
            Redirect("http://AnotherApplicaton/Home/LogOut");
        }

现在,当我点击注销链接其重定向到注销操作,并在注销操作其删除所有会话,但是当我点击浏览器的后退按钮它返回到previous页,会议还活着。有没有人有这个问题的解决方案。

Now when I click on the LogOut link its redirect to the LogOut action and in the LogOut action its delete all the session, but when I click on the back button of the browser its get back to the previous page and sessions are still alive. Does anyone have the solution of this problem.

推荐答案

如果您在使用窗体身份验证,那么这是你在找什么...

if you're using forms authentication then this is what you are looking for...

public ActionResult LogOut()
        {
            Session.Clear();
            FormsAuthentication.SignOut();
            Redirect("http://AnotherApplicaton/Home/LogOut");
        }

心连心

这篇关于从MVC注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆