Skip to main content

Action Selector in Asp.net Mvc

Action Selectors

Action selector are the attribute that applied to action method to handle a particular requests.
MVC 5 have following action selector attributes:

1) ActionName
2) NonAction
3) ActionVerbs


ActionName:

It allow us to specify different ActionName then the method name.


[ActionName("Student")]
public ActionResult StudentName(string stuName)
{
  
  return View();

}

In the above example, before specify [ActionName("Student")] , action method name was "StudentName" but after applying ActionName the new name of action method is "Student".



NonAction:

NonAction method indicates that the public method of a controller is not an action method. If you apply NonAction then it will not treat as a Method.



[NonAction]
public ActionResult StudentName(string stuName)
{
  
  return View();

}


ActionVerbs:

MVC framework support following ActionVerbs:

1) HttpGet
2) HttpPost
3) HttpPut
4) HttpDelete
5) HttpOptions
6) HttpPatch

In the next article we will learn about Models.

Click here to learn about Models


Comments