I am beginner in asp.net mvc.
I have 2 Controllers:
HomeController actions: index,about
url that i need:
index action url: mydomain
about action url: mydomain/about
OtherController actions: index
index action url: mydomain/other
MyCode That not works:
routes.MapRoute(
"Other",
"{controller}/{action}/{id}",
new { controller = "Other", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Thanks
For your Home Controller, to hit
you need
to hit
you need
For your Other Controller, to hit
you need
Note that, in all cases, the “name” parameter doesn’t really matter.