0

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
  • What does your MyCustomRoute class look like? Commented Mar 10, 2010 at 4:24
  • @mark123 - thanks for the interest, but I think I figured it out. I feel a little dumb not having seen that property before. I am a little suprised however that the MSDN documentation doesn't tell you this in big bold letters at the top of its "Routing for WebForms" example... Commented Mar 10, 2010 at 4:30

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.