2

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 looks 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?

dsolimano
  • 8,870
  • 3
  • 48
  • 63
Jack Smit
  • 3,093
  • 4
  • 30
  • 45
  • Possible duplicate of [.Net MVC Routing Catchall not working](http://stackoverflow.com/questions/318886/net-mvc-routing-catchall-not-working) – jgauffin May 17 '16 at 05:49

3 Answers3

1

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

halfer
  • 19,824
  • 17
  • 99
  • 186
Mahesh Velaga
  • 21,633
  • 5
  • 37
  • 59
1

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
  • 3,093
  • 4
  • 30
  • 45
0

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
  • 2,128
  • 2
  • 25
  • 39