So far (for brevity) I have one route in global.asax registered like this:
routes.Add(new LowercaseRoute("{action}/{id}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { controller = "Home", action = "Index", id = UrlParameter.Optional }),
DataTokens = rootNamespace
});
Where "rootNamespace" is
var rootNamespace = new RouteValueDictionary(new { namespaces = new[] { "MyApp.Web.Controllers" } });
LowercaseRoute inherits from Route and just makes all paths lowercase. I also have an area registered like this:
context.Routes.Add(new LowercaseRoute("admin/{controller}/{action}/{id}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { action = "List", id = UrlParameter.Optional }),
DataTokens = adminNamespace
});
Where adminNamespace is another namespace, same idea as in the default route, but with the right namespace. This works fine, I can access URLs that look like this:
http://example.com/contact <- default route, "Home" controller
http://example.com/admin/account <- area route, "Account" controller, default "List" action
The problem is that this
http://example.com/admin/home/contact
also works. There's no "home" controller with a "contact" action under the "admin" area. It pulls the right page from "/contact" but with URL being "/admin/home/contact".
Is there any way to prevent this from happening?
Thanks.