Logout from MVC

前端 未结 4 413
南旧
南旧 2021-01-07 09:56

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

[ 

        
相关标签:
4条回答
  • 2021-01-07 10:24

    The sessions are not alived; they are just cached.

    You can try to force refresh your page (ctrl+f5) and check this.

    0 讨论(0)
  • 2021-01-07 10:37

    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");
            }
    

    hth

    0 讨论(0)
  • 2021-01-07 10:43

    Hi got the solution. Actually I have used toke to login into my module and the token timeout was 5 second. If I Logged out and click on the back button of the browser before the 5 second then the Session_Start() event of glowal.ascx.cs is called again and read the token again and the create the session again. And if I click on the back button after the 5 second then session does not create. To solve this problem I does not allow the user to go to back through the browser. For this I have used the following code

    <script type="text/javascript">
    history.go(1);
    </script>
    
    0 讨论(0)
  • 2021-01-07 10:47

    The pages you visit in your browser are cached depending upon your caching settings in the browser. You need to prevent caching in ASP.net MVC so that they are not cached by the browser. After you do that try clearing your browsers cache and try loading the page again. Logout and try the back button. You should get a message saying that the page no longer exists or something.

    There are many ways of preventing your ASP.net pages from getting cached in the browser. One such way is to do this before the page is rendered.

    this.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1))
    this.Response.Cache.SetCacheability(HttpCacheability.NoCache)
    this.Response.Cache.SetNoStore()
    
    0 讨论(0)
提交回复
热议问题