开发者

Back button not requesting asp.net mvc get method

开发者 https://www.devze.com 2023-03-31 14:49 出处:网络
We are facing a specific p开发者_如何转开发roblem where in on click of backbutton, the default get method is not getting triggered in asp.net mvc

We are facing a specific p开发者_如何转开发roblem where in on click of backbutton, the default get method is not getting triggered in asp.net mvc

any specific solutions ?


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()
    {
        ........
    }


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号