While testing out some of the new features of the March preview of ASP.NET MVC, I found an interesting feature of the routing behavior. (alternative suggestions welcome)
Suppose you want to setup the route http://mywebsite/login but your default route in global.asax.cs is:
routes.Add(new Route("{controller}/{action}/{id}", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { action = "Index", id = "" }),
});
How about adding?
routes.Add(new Route("login", new MvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { controller = "Security", action = "Login", id = (string)null }),
});
Lest you find yourself throwing things and brushing up on your Jr. High vocabulary, note that the the default behavior (at least for now) is matching in order that the routes are added. First match wins. So, if you add the new route after the first, your url will get caught in the first route pattern and may violate your expectations.
A great way to look at mvc routes is to download the route debugger which is a dll and one line of debug code to give you this: