我有一個操作方法,我需要在點擊後退按鈕時執行。我之前通過禁用我的操作方法(Response.Cache.SetCacheability(HttpCacheability.NoCache))中的緩存來完成此操作。這不適用於其他操作方法。由於某些原因,當我禁用緩存並按下後退按鈕時?觸發我的操作方法在頁面過期什麼的問題可能是任何想法MVC後退按鈕問題
0
A
回答
1
有沒有辦法知道,在服務器端,如果頁面請求是後退按鈕的結果
更可能的是,以前的請求是一個帖子,而不是一個get,並且該帖子要求你重新發布數據。
7
嘗試以下,對我的偉大工程:
public class NoCacheAttribute : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
var response = filterContext.HttpContext.Response;
response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
response.Cache.SetValidUntilExpires(false);
response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
response.Cache.SetCacheability(HttpCacheability.NoCache);
response.Cache.SetNoStore();
}
}
public class HomeController : Controller
{
[NoCache]
public ActionResult Index()
{
// When we went to Foo and hit the Back button this action will be executed
// If you remove the [NoCache] attribute this will no longer be the case
return Content(@"<a href=""/home/foo"">Go to foo</a><div>" + DateTime.Now.ToLongTimeString() + @"</div>", "text/html");
}
public ActionResult Foo()
{
return Content(@"<a href=""/home/index"">Go back to index</a>", "text/html");
}
}
+0
看起來很有意思。謝謝! – Quadwwchs
相關問題
- 1. tornado.web.authenticated後退按鈕問題
- 2. UINavigationController後退按鈕問題
- 3. cakephp後退按鈕問題
- 4. PJAX:後退按鈕問題
- 5. 後退按鈕問題
- 6. 後退按鈕問題
- 7. UINavigationController後退按鈕問題
- 8. 後退按鈕angularjs問題
- 9. iframe後退按鈕問題(不想後退按鈕影響iframe)
- 10. 退出按鈕退出後的問題
- 11. MVC 4 - 註銷後的後退按鈕問題
- 12. mvc和後退按鈕
- 13. history.js後退按鈕的問題
- 14. IFrame導致後退按鈕問題
- 15. Windows Phone 7後退按鈕問題
- 16. Jsp,servlet後退按鈕問題
- 17. Chrome/Safari後退按鈕問題
- 18. signalr ie9後退前進按鈕問題
- 19. PJAX和Firefox後退按鈕問題
- 20. 瀏覽器後退按鈕問題
- 21. 與後退按鈕的JSF問題
- 22. JSONP + onbeforeunload +後退按鈕+問題
- 23. CodeIgniter問題與使用後退按鈕
- 24. AS3 Android的後退按鈕問題
- 25. UINavigationController後退按鈕操作問題
- 26. UI路由器後退按鈕問題
- 27. jquery 2 iframes後退按鈕問題
- 28. Android中的WebView後退按鈕問題?
- 29. Android的後退按鈕問題
- 30. Android Webview中的後退按鈕問題
這確實是一個帖子。謝謝! – Quadwwchs