0
我對緩存我的視圖沒有什麼問題。當我丟失我的票並註銷時,位置標頭不正確,並嘗試直接進入我以前的URL。ASP .NET MVC OutputCache錯誤的位置
示例:我在裏面/ Admin/Categories,然後由於afk太長而退出,所以我被重定向到/ Admin/Login。登錄後,我試圖去/管理/類別和緩存發送我/管理/登錄而不是/管理/類別。
我的代碼:
LOGIN CONTROLLER
[OutputCache(CacheProfile = "OneDayCache", VaryByParam = "None", VaryByCustom = "url")]
public ActionResult Index()
{
return View();
}
CATEGORIES CONTROLLER
[OutputCache(CacheProfile = "OneDayCache", VaryByParam = "None", VaryByCustom = "url")]
public ActionResult Index()
{
if (validations.ValidateTicket())
{
return View();
}
else
{
return RedirectToAction("Index", "Login");
}
}
validations.ValidateTicket()將返回true或false,它的工作好 - 這是沒問題的。
GLOBAL.ASAX.CS
public override string GetVaryByCustomString(HttpContext context, string arg)
{
if (arg == "url")
{
return context.Request.RawUrl;
}
return base.GetVaryByCustomString(context, arg);
}
的Web.config部分內:
<caching>
<outputCache enableOutputCache="true" omitVaryStar="true"></outputCache>
<outputCacheSettings>
<outputCacheProfiles>
<add name="OneDayCache" duration="86400" location="Client" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
緩存 - 登錄(/管理/登錄)
HTTP/1.1 200 OK
Cache-Control: private, max-age=86400
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Expires: Fri, 10 Feb 2017 20:35:45 GMT
Last-Modified: Thu, 09 Feb 2017 20:35:45 GMT
Vary: Accept-Encoding
Server: Microsoft-IIS/10.0
X-AspNetMvc-Version: 5.2
X-Frame-Options: SAMEORIGIN
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?TTpcUHJvamVrdHlcQU1CSVQtQ01TLU1WQ1xBTUJJVCBDTVMgTVZDXEFkbWluXExvZ2lu?=
X-Powered-By: ASP.NET
Date: Thu, 09 Feb 2017 20:35:45 GMT
Content-Length: 1113
緩存 - 分類(/管理/類別) - 看位置頭部這是錯誤的...
HTTP/1.1 302 Found
Cache-Control: private, max-age=86400
Content-Type: text/html; charset=utf-8
Expires: Fri, 10 Feb 2017 20:35:39 GMT
Last-Modified: Thu, 09 Feb 2017 20:35:39 GMT
Location: /Admin/Login
Server: Microsoft-IIS/10.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?TTpcUHJvamVrdHlcQU1CSVQtQ01TLU1WQ1xBTUJJVCBDTVMgTVZDXEFkbWluXENhdGVnb3JpZXM=?=
X-Powered-By: ASP.NET
Date: Thu, 09 Feb 2017 20:35:39 GMT
Content-Length: 439