views:

21

answers:

1

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  A: 

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.

maartenba
There is no parameter that takes into account RouteValues. Only variance by HttpParameters is supported (Querystring etc)
Malcolm Frexner
[OutputCache] already varies by RouteValues. This just automatically happens since ASP.NET output caching is associated with a particular URL, and RouteValues are components within the URL. So /Foo/Value1 will be cached separately from /Foo/Value2.
Levi
@Levi You are right. My test for variance was wrong.
Malcolm Frexner