Monday, 9 August 2010

ASP.Net Web Form Routing - Routing Problem

I have put together a web application project that made use of ASP.Net web form routing but I had some strange behaviour on a certain route.

The route i had added to the routes tables was:

routes.Add("Admin", new Route
new PageRouteHandler("~/Admin/help.aspx", true)));

This was to point to a the help.aspx page in the admin folder.

The Problem

When i attempted to browse to this route -


Rather than the page all i got was a directory listing in the web page.


It appears the routing engine doesnt like a route value to have the same name as the folder it is pointing to.

All I had to do was rename the folder (or route value eg. and it all started working again.

Im not sure if this is a bug or a feature!

Please post a comment if you know what thy happened.


1 comment:

Anonymous said...

It's intentional. Routing will not happen if the url actually maps to a physical file. See the sction Scenarios when routing is not applied at the bottom: