ActionResult をキャッシュしようとしています。特定の ActionResult で、Cookie にデータを書き込んでいます。そのアクションの結果では、出力キャッシュが機能していません。Response.Cookies を使用していない他のすべてのアクションで正常に動作します。この問題を解決するのを手伝ってください。
ASP.NET MVC 4 を使用しています
編集
(コード付き)
[OutputCache(Duration = 8000, VaryByParam = "*")]
public ActionResult List(SearchViewModel searchViewModel, int page = 1, int mode = 1)
{
HttpCookie ck = Request.Cookies["Geo"];
string lat = string.IsNullOrEmpty(Request.Params["lat"]) ? null : Request.Params["lat"];
string lng = string.IsNullOrEmpty(Request.Params["lng"]) ? null : Request.Params["lng"];
if (ck == null)
{
ck = new HttpCookie("Geo");
Response.Cookies.Add(ck);
}
if (lat != null)
{
ck["Lat"] = lat;
ck["Lon"] = lng;
ck.Expires = DateTime.Now.AddMonths(2);
Response.Cookies.Set(ck);
//this is the code which causes problem. If I remove this section catching will work
//other logic goes here..
}
}