How do I prevent caching in Internet Explorer?

I am developing a web application in ASP.NET and in some pages I want them to not cache data using the following code:

protected override void OnInit(EventArgs e)
{
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetNoStore();
    Response.Cache.SetExpires(DateTime.MinValue);

    base.OnInit(e);
}

      

This works as it should, but now when the user tries to refresh the page after a postback (like saving data), the browser tells the user that the action will be called twice if he continues, and asks you if you want to continue or not. If you reverse this on Chrome or Firefox, the page still has the current state - which is exactly what I want, but it is not valid in IE.

Is there a way to achieve the same behavior for Internet Explorer?

+3


source to share


1 answer


You may have to take a different approach. Try to create a custom confirmation box to catch / reverse the update action:

http://devzone.co.in/show-confirmation-box-page-refresh-page-unload-using-javascript/



Execute the function before updating (although there is a comment in this solution that says it doesn't work with FireFox).

+1


source







All Articles