开发者

asp.net mvc disable ajax cache

开发者 https://www.devze.com 2023-01-23 02:56 出处:网络
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开发者_高级

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

精彩评论

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

关注公众号