Caching with variation by RouteValue

2019-08-16 05:00发布

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

ie www.mysite.com/Home/About/Value1 is different then www.mysite.com/Home/About/Value2.

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.

EDIT

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

1条回答
爷、活的狠高调
2楼-- · 2019-08-16 05:05

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.

查看更多
登录 后发表回答