我有一个jQuery $.post回到MVC 4控制器,它将返回一个使用POST中发送的数据渲染的PartialViewResult.调试部分视图和控制器时,正在接收正确的数据并将其作为视图模型发送到部分视图.问题是,当分析在
AJAX结果中发回的
HTML时,它包含来自原始页面刷新的看似“缓存”的数据.
我知道HTTP Post请求不会在浏览器中缓存,所以这不是问题.我还将OutputCache属性的设置设置为NoStore = true等.
调节器
[OutputCache(NoStore = true,Duration = 0,varyByParam = "*")] public partial class MyController : Controller { ... [HttpPost] public virtual ActionResult UpdatePartial(Myviewmodel myVm) { return this.PartialView("My/_Partial",myVm); } }
JS
$('.someButton').click(function () { $.post(myAjaxUrl,$('form').serialize(),function (data) { $('#myContent').html(data); }); });