Output Cache problem on ViewEngine that use 2 separate view for 1 controller

喜欢而已 提交于 2019-12-04 05:42:24

问题


http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx

To the sake of simplicity, please try out this. Basically, I am trying to do the mobile view engine, but then i found out that I have outputcache, which will cache one of 2 view (PC view) and then when i tried to access through mobile, it automatic show PC view.

So is there anyway to avoid this problem while still keeping the outputcache?

Thanks


回答1:


Is your problem that out of the box variance from Outputcache (varibyparam, varybycostum, varybyquerystring) is not enough?

If you need a cache that has variance by some route value then this might help you.

http://blog.stevensanderson.com/2008/10/15/partial-output-caching-in-aspnet-mvc/

or this: http://blog.maartenballiauw.be/post/2008/06/Creating-an-ASPNET-MVC-OutputCache-ActionFilterAttribute.aspx

I havn't tried these solutions but maybe they get you started.

EDIT At the time I wrote this answer I thought that Outputcache has no varinace by route values. But it realy has. Each URL has its own cache entry.



来源:https://stackoverflow.com/questions/2209526/output-cache-problem-on-viewengine-that-use-2-separate-view-for-1-controller

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