Asp.Net MVC Exploring Controllers in-depth Part 3

Asp.Net MVC Exploring Controllers in-depth Part 3 Action Selectors

When the MVC Framework is selecting one of the controller public methods to invoke as an action, it will use any

action selector attribute that might be present to define the correct action to invoke.

  1. ActionName
  2. AcceptVerbs
    • HttpPost
    • HttpGet

ActionName: When we apply this to a controller action it will specify the action name for that method.

For the Index method, we have bellow we no longer reach this method as action name “Index”. We have to reach this method as “Start”. (http://localhost:123/Home/Start)

AcceptVerbs: Http verbs allow us to reach a particular action we can say an action method is reachable with:

  1. [HttpGet] or [AcceptVerbs(HttpVerbs.Get)]
  2. [HttpPost] or [AcceptVerbs(HttpVerbs.Post)]

[RequireHttps] – Forces the Http request to be resent over Https.

HttpGet: Only get request will be served by the action method.

HttpPost: Only post request will be served by the action method.

 

Please follow and like us:
0

Leave a Reply

Your email address will not be published. Required fields are marked *