Web.Routing for the site root or homepage

Posted by Aquinas on Stack Overflow See other posts from Stack Overflow or by Aquinas
Published on 2010-04-01T22:30:58Z Indexed on 2010/04/01 22:33 UTC
Read the original article Hit count: 447

I am doing some work with Web.Routing, using it to have friendly urls and nice Rest like interfaces to a site that is essentially rendered by a single IHttpHandler. There are no webforms, the handler generates all the html/json and writes it as part of process request.

This works well for things like /Sites/Accounting for example, but I can't get it to work for the site root, i.e. '/'.

I have tried registering a route with an empty string, with 'default.aspx' (which is the empty aspx file I keep in my root folder to play nice with cassini and iis). I set RouteExistingFiles to false explicitly, but whatever I do when hitting the root url it still opens default.axpx, which has no code it inherits from, and contains a simple h1 tag to show that I've hit it.

I don't want to change the default file to redirect to a desired route, I just want the equivalent of a 'default' route that is applied when no other routes are found, similar to MVC.

For reference, the previous version of the site didn't use Web.Routing, but had a handler referenced in the web.config that was perfectly capable of intercepting requests for the root or default.aspx.

Specs: ASP.NET 3.5sp1, C#, no webforms, MVC or openrasta. Plain old IHttpHandlers.

© Stack Overflow or respective owner

Related posts about system.web.routing

Related posts about ihttphandler