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
("Admin",
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 -

domain.com/admin

Symptoms

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

Workaround

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. domain.com/admin/help) 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.

Thanks