Should I leave the Default Route in if it's not adding any benefit?
I have a RouteConfig.cs file that looks like this:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Dashboard",
url: "{controller}/{action}",
defaults: new { controller = "JobDashboard", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "JobDashboard", action = "Index", enumDigit = UrlParameter.Optional }
);
routes.MapRoute(
name: "Login",
url: "{controller}/{action}",
defaults: new { controller = "Account", action = "Login" }
);
}
If I only have the Default and Login Routes and the user goes to the root of the site (eg www.sitename.com), then the user always goes to the Login page. I don't want them going to the Login page after they've logged in, and after a little bit of digging I discovered that MVC4 always sorts Route Order Importance by Custom Route first, and then the Default Route.
I created the Dashboard route, and everything is working fine. I then took out the Default route because it didn't seem needed. Nothing seems to be affected by removing the Default Route, and that leads me to the question, should I leave the Default Route in there?
I seem to recall that having a Default Route is good practice, but if it's not adding anything to the solution, is there a good reason to keep it around?