views:

49

answers:

1

I'm using the System.Web.Routing.UrlRoutingModule.

With that I'm writing:

routes.Add(new Route(@"cart/add", new RouteHandler("~/Order/CartAdd.ashx")));
routes.Add(new Route(@"cart/delete", new RouteHandler("~/Order/CartDelete.ashx")));
...

And I also have one route called:

routes.Add(new Route(@"{*url}", new RouteHandler("~/Error/PageNotFound.ashx")));

But if I go directy to /Order/CartAdd.ashx I never enter the routing. It goes directly to that handler. And if I go to /Order/ I get a 403.14 error.

How do I instead catch those urls with the routing?

+1  A: 

In your route registration code, you can write something like this..

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.RouteExistingFiles = true;
        routes.IgnoreRoute("default.aspx");
        [...]

Which should force file requests through your routing rules.

Sciolist
Works fine, but IgnoreRoute doesn't work. But this does:routes.Add(new Route("default.aspx", new StopRoutingHandler()));
Allrameest