asp.net mvc - Call Controler not with full name -
i new asp.net mvc.we create controller 'admincontroller' call name of admin. how asp.net mvc handle don't need call controller full name?
the controller name specify in url not same class name, action name not same actual method on controller. there internal mapping between controller/action , class/method mvc when determining code needs executed.
the generic mapping rule is:
- for controllers, take controller name (
admin
) , add suffixcontroller
, search class name (admincontroller
). - for actions, take name of action (
details
) , search method on controller same name (actionresult details() {}
).
however, mvc supports explicit mapping of action method different name through actionname
attribute. thus, have action called edit
mapped method actionresult edituser() {}
example.
it possible future versions of mvc add similar controllername
attribute allows explicit mapping of particular controller name particular class. (in fact, hope do, solve problem providing different implementations of same controller name in different areas)
Comments
Post a Comment