与部分页面“客户方的OutputCache属性 [英] Outputcache attribute on clientside with partial pages'
问题描述
我的部分页面创建应用程序的菜单。我打电话使用的的RenderAction菜单局部视图。我想这样做是为了在客户端这部分页面保存
I a partial page creating the menu for application. I am calling the menu partial view using renderaction. I want to store this partial page on client side by doing this
[OutputCache(Duration=7200, Location =OutputCacheLocation.Client, NoStore= true)]
但我发现了以下错误
but i am getting the following error
OutputCacheAttribute for child actions only supports Duration, VaryByCustom, and VaryByParam values. Please do not set CacheProfile, Location, NoStore, SqlDependency, VaryByContentEncoding, or VaryByHeader values for child actions
任何替代这种
推荐答案
客户端缓存是不可能在MVC 3谐音客户端浏览器只是接收HTML,'谐音'只在服务器端存在的。
Client side caching is not possible for partials in MVC 3. The client browser just receives HTML, 'partials' only exist on the server side.
你为什么不使用服务器端缓存?
Why don't you use server side caching?
在你的菜单的内容依赖于用户,您可以将相关的用户信息添加到您的孩子操作的参数。例如:
When the content of your menu is dependent on the user, you could add the relevant user information to the parameters of your child action. For example:
[OutputCache(Duration=7200, VaryByParam="*")]
public PartialViewResult Menu(int userId)
{
...
}
这篇关于与部分页面“客户方的OutputCache属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!