When the application first starts up (i.e., when Application_Start() runs), this code
populates a global static RouteCollection object called RouteTable.Routes. That’s where the
application’s routing configuration lives.
MapRoute() adds an entry to the routing configuration.
Normal writing:
routes.MapRoute(
" Default ", // Route name
" {controller}/{action}/{id} ", // URL with parameters
new { controller = " Home ", action = " Index ", id = "" } // Parameter defaults
);
" Default ", // Route name
" {controller}/{action}/{id} ", // URL with parameters
new { controller = " Home ", action = " Index ", id = "" } // Parameter defaults
);
Equivalent to:
Route myRoute =
new Route(
"
{controller}/{action}/{id}
",
new MvcRouteHandler())
{
Defaults = new RouteValueDictionary( new {
controller = " Home ", action = " Index ", id = ""
})
};
routes.Add( " Default ", myRoute);
{
Defaults = new RouteValueDictionary( new {
controller = " Home ", action = " Index ", id = ""
})
};
routes.Add( " Default ", myRoute);
Reproduced in: https: //www.cnblogs.com/davidgu/archive/2012/03/15/2398366.html