使用1个控制器的2个单独视图的ViewEngine上的输出缓存问题 [英] Output Cache problem on ViewEngine that use 2 separate view for 1 controller

查看:79
本文介绍了使用1个控制器的2个单独视图的ViewEngine上的输出缓存问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

为简单起见,请尝试一下.基本上,我试图做移动视图引擎,但是后来我发现我有outputcache,它将缓存2个视图之一(PC视图),然后当我尝试通过移动设备访问时,它会自动显示PC视图./p>

那么有什么办法可以避免这个问题,同时仍然保留outputcache?

谢谢

解决方案

您的问题是Outputcache的开箱即用变量(varibyparam,variablebycostum,variablebyquerystring)还不够吗?

如果您需要一个具有某些路由值差异的缓存,那么这可能会对您有所帮助.

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

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

我没有尝试过这些解决方案,但也许它们可以帮助您入门.

编辑 在我写这个答案的时候,我认为Outputcache按路由值没有任何变化.但确实如此.每个URL都有自己的缓存条目.

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

解决方案

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.

这篇关于使用1个控制器的2个单独视图的ViewEngine上的输出缓存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆