views:

392

answers:

3

My first route:

  //  Should work for /Admin, /Admin/Index, /Admin/listArticles
  routes.MapRoute(
      "Admin",                                              // Route name
      "Admin/{action}",                           // URL with parameters
      new { controller = "Admin", action = "Index" }  // Parameter defaults
  );

is not resolving the route(I use Phil Haack's Route Debugger) and even the last route, "Catch All" route does not work:

  //Maps any completely invalid routes to ErrorController.NotFound
  routes.MapRoute("Catch All", "{*path}",
      new { controller = "Error", action = "NotFound" }
  );

If I go to /Admin/listArticles it works but /Admin gives me Error 403.15 "The Web server is configured to not list the contents of this directory." that points me to the idea that no routing is used as it look for a physical file in a directory? This is a simple low-level route problem but I cannot get it to work and everybody gives me links to read (Yes I know MSDN is out there) but no real answers. I have researched routes and have tried but I am posting this because I cannot get it to work, any help, answers?

Thank you Jacj.

+1  A: 

The problem might be that you have added this route below the default route, all custom routes should be added above default route.

Thanks,
Mahesh Velaga.

Mahesh Velaga
A: 

Are you using IIS 6.0? If so it'll need to look like...

  //  Should work for /Admin, /Admin/Index, /Admin/listArticles
  routes.MapRoute(
      "Admin",                                              // Route name
      "Admin.mvc/{action}",                           // URL with parameters
      new { controller = "Admin", action = "Index" }  // Parameter defaults
  );

Where you need to set mvc as an application extension

RailRhoad
A: 

The answer to my question was that I had a route called /Admin and I wrote my error log to a directory /Admin/Error It seems that there is no overload to specify if the route should be resolved or if it is part of a physical directory.

Jack Smit