开发者

asp.net mvc disable ajax cache

I load list of data by using ajax and partial view(ascx) But I have a problem: my response is cached. I try to write Responce.Cache.SetExpires(DateTime.Now.AddDays(-1)) in ascx file but it i开发者_高级运维s not helped

In ASP.NET WebForms I've solved this by writing Responce.Cache.SetExpires(DateTime.Now.AddDays(-1)) in codebehind. So I'd like to know where can I write Responce.Cache.SetExpires(DateTime.Now.AddDays(-1)) to disable cache.


Use jQuery?

$.ajax({
 cache:false,
 ...
});

or Controller / Action set OutputCacheAttribute.

OutputCacheAttribute Class (System.Web.Mvc)


You should be using ajax POST to controller method that returns JsonResult if you want to load data from server asynchronously.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜