4

We are facing a specific problem where in on click of backbutton, the default get method is not getting triggered in asp.net mvc

any specific solutions ?

subramn
  • 843
  • 1
  • 8
  • 12

3 Answers3

6

if you want just one specific action to get from server every time use

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

as an attribute on your action like this

    [HttpGet]
    [OutputCache(NoStore = true, Duration = 1)]
    public ActionResult Index()
    {
        ........
    }
eiu165
  • 5,759
  • 9
  • 36
  • 58
5

If the browser has the page cached, it'll use the one from cache.

Try telling the response not to cache. You can do it with an ActionFilter or globally in Global.asax.

    httpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
    httpContext.Response.Cache.SetValidUntilExpires(false);
    httpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
    httpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
    httpContext.Response.Cache.SetNoStore();

More options here:

Disable browser cache for entire ASP.NET website

Community
  • 1
  • 1
John Smith
  • 213
  • 1
  • 4
0

Try this in your HTML section:

<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE">

That will stop the page from being cached by your browser.

Steve Woods
  • 488
  • 3
  • 8