Form 1: Define the default value of id in the action definition.
routes.MapRoute("MyRoute",
"{controller}/{action}/{id}",
new {controller = "Home", action = "Index", id = UrlParameter.Optional});
public ViewResult Index (int id = 0)
{
// ....
}
Form 2: Define the default value of id in the route definition.
routes.MapRoute("MyRoute",
"{controller}/{action}/{id}",
new {controller = "Home", action = "Index", id = 0});
My question: I think that the two forms above get the same routing result in MVC routing system. But I don't understand the difference of them by my effort.
(It's code snippet from relative source)