Back button does not request asp.net mvc get method

We are faced with a specific problem when, when clicking on the default button, the get method does not start by default in asp.net mvc

any specific solutions?

+4
source share
3 answers

If the browser has a cached page, it will use one of the cache.

Try not to answer the cache. You can do this with 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(); 

Additional options here:

Disable browser cache for the entire ASP.NET website

+5
source

if you want only one specific action to be received from the server each time using

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

as an attribute of your action, for example

  [HttpGet] [OutputCache(NoStore = true, Duration = 1)] public ActionResult Index() { ........ } 
+6
source

Try this in your HTML section:

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

This will result in the page not being cached by your browser.

0
source

Source: https://habr.com/ru/post/1369413/


All Articles