Action Selectors in Asp.net MVC


Action Selectors have used in Asp.net MVC action methods and these attributes applied to action methods.  it decides which action method gets invoked in response to the HTTP request and should be matched with the method name in the request URL.

Action Selectors in Asp.net MVC

Types of Action Selectors

  There are mainly 3 attributes are available in MVC5
      • ActionName
      • NonAction
      • ActionVerbs
ActionName attribute is used to give a different name than the action method name.

Example of Action Selectors

                 public class ATGController : Controller
                     {
                         [ActionName("check")]
                         public ActionResult CheckById(int id)
                             {
                                // check from the database
                                  return View();
                             }
                     }


NonAction selectors are the methods of controller. they are not action methods.
Example for NonAction Selector

               public class ATGController : Controller
                   {
                      [NonAction]
                      public CheckById(int id)
                            {
                              return checkList.Where(s => s.CheckId ==id).FirstOrDefault();
                             }
                     }





Previous Post Next Post