I haven’t found a clear answer to this, so can someone help me?
If we have a URL like this
www.website.com/results.aspx?listingtype=2&propertytype=1&location=alaska
Then we can set
<%@ OutputCache Duration="120" VaryByParam="listingtype;propertytype;location" %>
But I use routing, so my url looks like this:
www.website.com/buy/houses/alaska
or for example
www.website.com/rent/condominiums/nevada
How do I use the RouteValues in VaryByParam, or can I set it from code-behind or how?
I am not using MVC, this is an ASP.NET website
Edit: (For non ASP.NET MVC apps)
How about this:
Make the OutputCache definition this:
In the Global.asax.cs add these methods:
Old Content:
If you simply put OutputCache on your action method and make all your route parts part of your action method, something like this:
The the framework will automatically vary the cache by these items for you (See: http://aspalliance.com/2035_Announcing_ASPNET_MVC_3_Release_Candidate_2_.4)