views:

11

answers:

0

I have a ASP.NET 4.0 web application that uses System.Web.Routing.RouteTable for some routing. In my global.asax I have this code:

protected void Application_Start(object sender, EventArgs e)
{
    RouteTable.Routes.Add(new Route("", new PageRouteHandler("~/Documentation/Index.aspx")));
}

The application resides in a virtual directory called Data. If I request http://localhost/Data/ I get redirected to http://localhost/Data/Documentation/Index.aspx as expected.

If I request http://localhost/Data without the trailing slash I get redirected to http://localhost/DataDocumentation/Index.aspx which gives me a 404. Question: Is there a way to fix this?

By the way, the reason I don't just put a Default.aspx containing a Response.Redirect in the root folder is because I need a routing rule like this

RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(Service.AnonymousUserService)));

contining rules like these:

 [WebGet(UriTemplate = "{userGuid}/Messages/Newest", ResponseFormat = WebMessageFormat.Xml)]
public XElement GetNewestMessages(string userGuid)
{
    ...
}