user1102203
user1102203

Reputation: 11

ASP.NET MVC 3 OutputCache Routing : 2 routes for 1 action make 2 cached pages

"The outputcache is caching 2 pages (there's 2 URLs) for just 1 same action" WHY ?? I tought outputcache was looking for routedata values..., no?

So, On my website, i have 2 URLs for the Home page :

"http://www.domain.com/"

and

"http://www.domain.com/search/mysearchpage.htm"

Here are the routes :

routes.MapRoute(
                "nameofmyroute",
                "search/mysearchpage.htm",
                new { controller = "Search", action = "do", id = "" },
                new { controller = @"[^\.]*" }
            );

routes.MapRoute("Default",
               "{controller}/{action}/{id}",    
                new { controller = "Search", action = "do", id = "" },
                new { controller = @"[^\.]*" }
            );

Here is my caching config:

<add name="defaultcache"
duration="3600"
enabled="true" 
location="ServerAndClient" />

When i ask for "/" url =>my action is firing and the all the action is done. When i re-ask for "/" => my action is not fired => cool it's working ! it's taken from the cache.

But: When i ask for "/search/mysearchpage.htm" => my action is also fired ! I don't understand why...

PS:There's no parameter on my Action.

Do you have an explanation for that ? Thanks a lot ! :)

Sorry for my english.

Upvotes: 1

Views: 406

Answers (1)

iam_martin
iam_martin

Reputation: 86

ASP.NET Outputcache provider is based on Url and not your routing.

Upvotes: 2

Related Questions