views:

32

answers:

1

If you cannot turn on wildcard mapping for IIS (shared hosting) or can't be bothered (lazyness) can you still use ASP.Net routing if your routes end in one of the "known" asp.net extensions...like ending all routes with .ashx, .aspx etc?

From Chris Cavenagh's blog, could his examples of:

var routeHandler = new WebFormRouteHandler<Page>( "~/MyPage.aspx" );

    routes.Add( new Route( "{page}", routeHandler ) );
    routes.Add( new Route( "AccountServices/{page}", routeHandler ) );
    routes.Add( new Route( "Default.aspx", routeHandler ) );

be done without wildcard mapping like this:

var routeHandler = new WebFormRouteHandler<Page>( "~/MyPage.aspx" );

    routes.Add( new Route( "{page}/view.ashx", routeHandler ) );
    routes.Add( new Route( "AccountServices/{page}/view.aspx", routeHandler ) );
    routes.Add( new Route( "Default.aspx", routeHandler ) );

I'm presuming so as his last route is Default.aspx, but he hasn't included any route data with that...Is there a better way? Provided this works, it looks like the best idea as if the application is moved or wildcard mapping can be turned on, only the routes need to change...

A: 

Yes this works...still kind of annoying to have to include an extension...but it works.

davidsleeps