I am just going through on MVC routing frame work. I am bit confused on parameter taken by RouteCollection.MapRoute method.
If I took a trditional example of below request
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
- List item
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
}
It's mapped with following signatures
public static Route MapRoute(
this RouteCollection routes,
string name,
string url,
Object defaults
)
My question is regarding "Object defaults" ,
- Why we are using it as
new { controller = "Home", action = "Index", id = "" } - Is this is a fixed format?
- How can
CLR interpret sequenceof parameter?
Follow up questions:
a. Why we decorate controller,action or id inside a bracket {}?
b. Is there any match in between URL specify and defaults?