2

i am working on a site . for that i created a LogIn system after LogIn user can see his home page . but i am facing a problem . cos when user logged out i delete all the sessions and cookie . and loged out process don in a good way . after that when i insert user home page url in browser and hit enter .

like this : www.exam.com/user/home

the redirect is don in a good way and server redirect me on ligin page .

but if i do this thing by back button of the browser. browser show me the user home page . this is the issue .

i also check this thing with facebook . and the don good job .

please help me to solve this issue . cos i tried my all affords but nothing is working.

thanks

leppie
  • 115,091
  • 17
  • 196
  • 297
  • possible duplicate of [How to clear browser cache on browser back button click in MVC4?](http://stackoverflow.com/questions/16337149/how-to-clear-browser-cache-on-browser-back-button-click-in-mvc4) – NotMe Sep 19 '14 at 18:26

3 Answers3

3

In my opinion better solution is to set cache life in attribute to function/controller. It can be done by adding:

[HttpGet, OutputCache(NoStore = true, Duration = 1)] 

before function or whole controller.

Jacob Sobus
  • 961
  • 16
  • 25
1

You have to set the pages to expire immediately. For example:

    // disabling caching for all parent pages
    protected override void OnInit( EventArgs e ) {
        base.OnInit(e);
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.AppendHeader("Cache-Control", "no-cache, no-store");
        Response.Cache.SetExpires(DateTime.UtcNow.AddYears(-1));
    }

I have that in my master pages. This tells the browser NOT to cache the page. Because it's no longer cached, if the person hits the back button it will cause the browser to send the page request to your server, at which point you can redirect them to a login page.

NotMe
  • 87,343
  • 27
  • 171
  • 245
1

sorry for that but i got the answer

this is on that place

How to clear browser cache on browser back button click in MVC4?

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
Community
  • 1
  • 1