Say I only have this route:
routes.MapRoute("MyRoute", "{controller}/{action}/{id}",
new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional
});
We see what our start page will be Home/Index.
And let me say that I created a binding element using this code in a view:
@Html.ActionLink("This targets another controller","Index", "Admin")
When I create the view, you will see the following HTML:
<a href="/Admin">This targets another controller</a>
Our URL request, which targets a Indexcontroller action method Admin, was expressed as a /Adminmethod ActionLink. The routing system is pretty smart and knows that the route defined in the application will use the Indexdefault action method , allowing it to skip unnecessary segments.
And the question is:
If I change the route as:
routes.MapRoute("MyRoute", "{controller}/{action}/{id}/{name}",
new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional,
name = UrlParameter.Optional
});
or like:
routes.MapRoute("Default", "{controller}/{action}/{id}/{*catchall}",
new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional
});
Then the following HTML will be generated:
<a href="/Admin/Index">This targets another controller</a>
, ?