I'm trying to cache an ActionResult. In a particular ActionResult I'm writing some data to cookies. The output cache is not working in that action result. Its working fine with all other actions where I'm not using Response.Cookies. Please help me to resolve this issue.
I'm using ASP.NET MVC 4
Edit
(Code included)
[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..
}
}