Outputcache attribute on clientside with partial pages'

爷,独闯天下 提交于 2019-12-01 20:55:54

问题


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

Any alternate to this


回答1:


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)
{
   ...
}


来源:https://stackoverflow.com/questions/6410431/outputcache-attribute-on-clientside-with-partial-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!