I know it's the general approach:
routes.MapRoute
(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
But If I try like this:
routes.MapRoute
(
name: "Defaults",
url: "Home/Index/1"
);
It will not give any error to run the project. I have Controller = Home
Action = Index()
in my HomeController
but why It is giving error while I type this http://localhost:1702/Home/Index/1
in my browser?
Error: The matched route does not include a 'controller' route value, which is required.
Which part is mandatory in Routing?
Another question is: Why we need Route Name
?? If I give name=""
, it works fine even more than one Route is exists like name=""