Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh ASP .NET MVC page when hitting browser back button

I just found that when I click browser back button on any ASP .NET MVC page nothing happens and page is not going be updated. And only if you click F5 it will be updated only.

The main problem that I do some changes of DOM of the page i.e. add table rows select radio-buttons and etc and when I go back to page by hitting browser back button I have see no changes.

How it can be resolved for ASP .NET MVC 5?

Thank for any clue...

P.S. I have read http://forums.asp.net/t/1304752.aspx?how+to+refresh+page+when+hitting+back+button but it does not help...

like image 616
Friend Avatar asked Feb 20 '14 11:02

Friend


People also ask

How do I stop page reload/refresh on hit back button?

You have to detect browser back button event and pass as an input of the page you want do prevent URL reload that indicates you if you came from a back button click. this code: $(window). on('popstate', function(event) { alert("pop"); });

How do I stop asp net from going back to previous page?

Master, I have used the code that to prevent the user from going back to previous pages after logout. function preventBack() { window. history. forward(); } setTimeout("preventBack()", 0); window.

How do I go back in asp net?

We can use ASP button or Link Button to: If you use Hyper Link: <a href="javascript: history.go(-1)">Go Back</a>


1 Answers

Here is a proper solution http://dotscrapbook.wordpress.com/2011/02/02/handling-a-browser-back-button-press-with-mvc/.

[HttpGet]
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")] 
public ActionResult MyView()
{
  ...
}
like image 188
Friend Avatar answered Sep 21 '22 22:09

Friend