1. Description of Controllerdescriptor
The Controller's action method has some of the following characteristics:
1.1 Actionnameattribute attribute he inherits from System.Web.Mvc.ActionNameSelectorAttribute abstract class
Actionnameselectorattribute uses its abstract method isvalidname to determine whether the specified action name matches the target action method.
The following code snippet:
After adding the Actionnameattribute attribute, the Access action will match the actionname instead of the actionnames note that there is a "s" Behind the Aciton method
[ActionName ("actionname")] Public actionresult actionnames () { return Json ("", Jsonrequestbehavior.allowget); }
Actionnameselectorattribute differs from Actionmethodselectorattribute: both have action filtering, which is for the action name and whether it matches the request
There are 7 types of 1.2 Actionmethodselectorattribute (:
Httpget,httppost,httpput,httpdelete,httphead,httpoption,httppatch. The following code snippet:
[HttpGet] Public actionresult HttpMethod () { return Content (""); }
1.3 Acceptverbsattribute characteristics, It differs from Actionmethodselectorattribute in that it can match multiple HTTP methods at the same time, as in the following code snippet:
This makes it possible to use a post or GET request at the same time, and if you remove get, you can only use the POST request.
[Acceptverbs (Httpverbs.post | Httpverbs.get)] public actionresult acceptverbs () { return Json (" ", Jsonrequestbehavior.allowget); }
1.4 Nonactionattribute Features:
The Action method that sets the Nonactionattribute attribute is always excluded from the candidate range when requested, as in the following code snippet
When the Nonactionattribute attribute is added, the access will appear HTTP 404. Error
[nonaction] Public actionresult nonactions () { return Content ("nonactionattribute"); }
2.ActionDescriptor
3.ParameterDescriptor
MVC4 Model Controllerdescriptor