本文介绍了通过RouteValue进行变化的缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动作,其结果取决于某些路由值.

I have an Action that has diferent results depending on some route value.

www.mysite.com/Home/About/Value1 www.mysite.com/Home/About/Value2 不同.

我是否有可能在控制器Home中的操作About中使用 OutputCache ,并为 www.mysite.com/Home/About/Value1 www.mysite.com/Home/关于/Value2 ?我知道我可以在模型级别使用缓存,但是我想在操作上使用 OutputCache .

Is there any chance I can use OutputCache on the action About in controller Home with diferent output for www.mysite.com/Home/About/Value1 and www.mysite.com/Home/About/Value2? I know I can use caching on model level, but I want to use OutputCache on the action.

编辑

www.mysite.com/Home/About/Value1 ,然后 www.mysite.com/Home/About/Value2 实际上具有不同的缓存条目,如Levi所述.

www.mysite.com/Home/About/Value1 and then www.mysite.com/Home/About/Value2 actually have different cache entries as stated by Levi

推荐答案

只需将 [OutputCache()] 属性添加到About操作方法中.如果要更改它,可以使用 OutputCache属性中的参数之一.

Simply add the [OutputCache()] attribute to your About action method. If you want to vary it, you can use one of the parameters in the OutputCache attribute.

这篇关于通过RouteValue进行变化的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 23:29