Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 防止用户在asp.net mvc中注销后返回_Asp.net Mvc_Caching_Browser Cache - Fatal编程技术网

Asp.net mvc 防止用户在asp.net mvc中注销后返回

Asp.net mvc 防止用户在asp.net mvc中注销后返回,asp.net-mvc,caching,browser-cache,Asp.net Mvc,Caching,Browser Cache,我已经尝试了所有可能的方法来防止用户在注销后返回。但都不管用。我试过- Response.ClearHeaders(); Response.Cache.SetAllowResponseInBrowserHistory(false); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); Response.Cache.SetRevalidation(HttpCacheReval

我已经尝试了所有可能的方法来防止用户在注销后返回。但都不管用。我试过-

Response.ClearHeaders();

Response.Cache.SetAllowResponseInBrowserHistory(false);
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCach‌​es);

Response.AppendHeader("Cache-Control", "no-cache"); 
Response.AppendHeader("Cache-Control", "private"); 
Response.AppendHeader("Cache-Control", "no-store"); 
Response.AppendHeader("Cache-Control", "must-revalidate"); 
Response.AppendHeader("Cache-Control", "max-stale=0");  
Response.AppendHeader("Cache-Control", "post-check=0"); 
Response.AppendHeader("Cache-Control", "pre-check=0");  
Response.AppendHeader("Pragma", "no-cache"); 
Response.AppendHeader("Expires", "Mon, 26 Jul 2000 05:00:00 GMT"); 

Response.Cache.SetCacheability(HttpCacheability.NoCache);  
Response.Cache.AppendCacheExtension("no-store, must-revalidate");
Response.AppendHeader("Pragma", "no-cache"); 
Response.AppendHeader("Expires", "0"); 
我在铬上测试过(第56节)。上述代码不能阻止用户在注销后返回


有什么想法吗???

转到Global.asax.cs文件,使用下面给出的代码清除应用程序中的缓存(希望有此帮助)——


将这行代码粘贴到要防止返回的控制器上方

[System.Web.Mvc.OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]


请把它标为答案并投票表决。如果这篇文章对你有帮助。
[System.Web.Mvc.OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
 [System.Web.Mvc.OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
    public ActionResult Logout()
    {
        FormsAuthentication.SignOut();
        Session["Username"] = null;
        Session.RemoveAll();
        Session.Abandon();

        return RedirectToAction("Index", "Login");
    }