I am new with ASP.NET MVC.we create a controller like this ‘AdminController’ but call it only with the name of Admin. How ASP.NET MVC handle this that we don’t need to call controller with full name?
I am new with ASP.NET MVC.we create a controller like this ‘AdminController’ but call
Share
The controller name you specify in the URL is not the same as the class name, just as the action name is not the same as the actual method that on the controller. There is internal mapping between the controller/action and the class/method that MVC does when determining what code needs to be executed.
The generic mapping rule is:
Admin) and add the suffixControllerto it and search for a class with this name (AdminController).Details) and search for a method on the controller with the same name (ActionResult Details() {}).However, currently MVC supports explicit mapping of an action to a method with different name through the
ActionNameattribute. Thus, you could have an action calledEditthat is mapped to a methodActionResult EditUser() {}for example.It is possible that future versions of MVC could add also a similar
ControllerNameattribute that allows explicit mapping of a particular controller name to particular class. (In fact, I hope they do, to help solve the problem with providing different implementations of the same controller name in different areas)