我使用SQL Server的上传图片和上传的图片会立即反映在网格below.my问题是当过我改变或编辑图片,图片将在数据库中更改,但网格显示之前我删除的图片。我必须注销并再次查看这些更改。有什么办法可以解决这个问题吗?每当网格重新加载时,是否有任何方法可以清除缓存?
0
A
回答
0
您可以尝试在下面的帖子中编写自己的属性,例如[no-cache],并且可以在控制器上使用它来防止缓存。
Prevent Caching in ASP.NET MVC for specific actions using an attribute
http://dotnetnsqlcorner.blogspot.co.uk/2012/09/disable-caching-for-controller-action.html?m=1
要禁用客户端缓存,你也可以在你的行动结果使用[outputcacheattattribute。以下文章可能会有帮助
[OutputCacheAttribute(VaryByParam = "*", Duration = 0, NoStore = true)]
How can I disable client side and proxy caching in ASP.NET MVC?
有禁用缓存以及其他方式,,但我想上面的两种方法应该做的工作之一。希望这有助于
0
您可以使用特定的catche的时间到项目:
只要看看这个: http://dotnet.dzone.com/articles/programmatically-clearing-0
和使用jQuery的Ajax然后如果客户端形成缓存使用::
$.ajax({
cache: false
//rest of your ajax setup
});
0
您可以将操作方法,并在你的Ajax调用创建除了cache: false
无缓存行为过滤器的属性。
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public sealed class NoCacheAttribute : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
filterContext.HttpContext.Response.Cache.SetNoStore();
base.OnResultExecuting(filterContext);
}
}
这很好地解释了Here。希望能帮助到你。
相关问题
- 1. 清除缓存
- 2. 缓存清除
- 3. Django缓存 - 清除缓存
- 4. FRAMESET中的清除缓存
- 5. 从MVC3应用程序中清除IIS缓存
- 6. 清除帧缓存
- 7. 清除memory_get_peak_usage缓存
- 8. 清除缓存,ObjectCacheManager
- 9. SILEX清除缓存
- 10. repcached清除缓存
- 11. 清除asp缓存?
- 12. 清除缓存7
- 13. 清除PhoneGap缓存
- 14. 清除ADF缓存
- 15. 清除PivotItem缓存
- 16. 清除UITableView缓存
- 17. window.location.reload清除缓存
- 18. 清除缓存7.3
- 19. 清除dom缓存
- 20. 清除ActiveRecord缓存
- 21. 清除bitbucket缓存
- 22. SDWebImage清除缓存
- 23. 清除NSURLConnection缓存
- 24. 清除SDWebImage缓存
- 25. Wampserver缓存清除
- 26. MVC3从控制器问题清除缓存的actionResult问题
- 27. plone.app.caching和settings清除清除缓存
- 28. 清除Master.Page上的缓存
- 29. Linux的清除缓存
- 30. 清除“缓存”的onDestroy
尝试刷新页面。不是最好的做法,但我认为会起作用。 –