Reputation: 1511
Simplifying, in my First page, I have this:
$(function () {
check();
})
function check() {
$.get("/MyController/MyAction/", function (data) {
if(data != undefined && data != "")
{
window.location.href = data;
}
})
}
this works well, but if the user comes back on the page (using browser go back button) the jquery get function doesn't reach to the controller and the data variable is blank. Why jquery get function doesn't execute my controller action? I have the same result using ajax:
$.ajax({
url: "/MyController/MyAction/",
})
.done(function (data) {
if(data != undefined && data != "")
{
window.location.href = data;
}
});
Upvotes: 1
Views: 322
Reputation: 25875
Most browsers load pages from the cache when you use the back button.
To prevent this, you can use the Cache-Control HTTP Header:
Cache-Control: no-cache, max-age=0, must-revalidate, no-store
See How to Defeat the Browser Back Button Cache and HTTP Caching FAQ
Upvotes: 3