How do routes work (by default)?
Go back to the default route, which looks something like this:
routes.MapRoute(
// Route name
"Default",
// URL with parameters
"{controller}/{action}/{id}",
// Parameter defaults
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Try to understand how it works.
If you go to /, it will trigger a Indexcontroller action Home; Optional Id has been omitted.
If you go to /C, it will trigger a Indexcontroller action C; Optional Id has been omitted.
If you go to /C/A, it will trigger a Acontroller action C; Optional Id has been omitted.
If you go in /C/A/1, it invokes a Acontroller action Cwith an identifier 1.
, URL- /, /C, /C/A /C/A/1, C - , A - . ? , .
, HomeController SummaryController Show.
/Summary/Show/1 SummaryController.Show(1)
, (/Controller/Id) ?
, , /Summary/1 SummaryController.Show(1).
:
routes.MapRoute(
"Summary",
"Summary/{id}",
new { controller = "Summary", action = "Show" }
);
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
, Home, Default. Summary, , URL- Summary/{id} . , Show Summary id ; , ...
, Summary, .
:. . , . , , ...