thirdLecture
thirdLecture
Outlines:
Action selector is the attribute that can be applied to the action methods.
It helps routing engine to select the correct action method to handle a
particular request.
MVC 5 includes the following action selector attributes:
1. ActionName
2. NonAction
3. ActionVerbs
ActionName
The ActionVerbs selector is used when you want to control the selection of
an action method based on a Http request method.
For example, you can define two different action methods with the same
name but one action method responds to an HTTP Get request and
another action method responds to an HTTP Post request.
MVC framework supports different ActionVerbs, such as HttpGet, HttpPost,
HttpPut, HttpDelete, HttpOptions & HttpPatch.
You can apply these attributes to action method to indicate the kind of
Http request the action method supports.
If you do not apply any attribute then it considers it a GET request by
default.
ActionVerbs
HTTP Methods
Different action methods supports different ActionVerbs
Multiple HTTP verbs using AcceptVerbs
You can also apply multiple http verbs using AcceptVerbs attribute.
GetAndPostAction method supports both, GET and POST
ActionVerbs in the following example:
ASP.NET MVC - Model
In the Add View dialogue box, keep the view name as Index.
It's good practice to keep the view name the same as the action
method name so that you don't have to specify view name explicitly in the
action method while returning the view.
Add View dialogue box
THE END!