Here we will learn what are the action methods in asp.net mvc and how to define urls for action method in asp.net mvc with example.
Let’s start understanding what Action method is? when any user want to access website or application in asp.net mvc user enter URL in browser like as shown below
In above URL you can see that PersonDetails is controller and Index is action method which user is entering to invoke action method index by enter this URL in browser.
When controller gets request by browser that controller will invoke method inside it . In case if method not found in controller then it will popup error saying http not found exception.
The method with ActionResult in asp.net mvc is called as Action Methods which return various View Results. For example following is the PersonDetailsController code snippet. You will see that Controller is a Class and Index is a Method in side that class. Here Index is the action method of PersonDetailsController
public class PersonDetailsController : Controller
// GET: /PersonDetails/
public ActionResult Index()
This is how we can define action methods and urls for action methods in asp.net mvc application.