views:

42

answers:

1

I am trying to cut over an existing WebForms app to use Routing, and want to do it in phases. However, I am running into some issues with a particular route:

//I want to catch existing calls to .aspx pages, but force them through  
// a route, so I can eventually drop the .aspx extension  
new Route("{page}.aspx", new MyCustomRoute());

This isn't working at all, as calls to [SomePage].aspx are never tripping this route... If I change the route to look like this:

//Same thing sans .aspx extension
new Route("{page}", new MyCustomRoute());

All calls to [SomePage] are getting picked up. Any ideas?

+2  A: 

Ok, so now I feel stupid...

Turns out there is this little property on the RouteCollection class called RouteExistingFiles which is false by default. Apparently ASP.Net routing gives precedence to existing files before turning them over to routing, so any calls to existing pages would obviously not be handled by my routes. Setting this property to true resolves my issue, all though it may have unintended side effects to which I am as of yet unaware.

Josh