Wednesday, August 3, 2016

What are Action methods in ASP.NET MVC?

All the public methods of a Controller class are called Action methods.
Action methods is responsible for accept the request from user and with the help of Model and passing the results back to the View. 
Action method with the following restrictions:
  1. Action method must be public. It cannot be private or protected
  2. Action method cannot be overloaded
  3. Action method cannot be a static method.



Action method are return ActionResult.
If you want to a public action methods  are not accessible from the URL. You decorate with NONACTION attribute.
E.g.

[NonAction]
public void AddressInfo(){
// some code inside here
}
[NonAction]
public ActionResult Address(){
// some code inside here
return View();
}

No comments:

Post a Comment

Hash Table in C#

 The Hashtable is a non-generic collection and used to store the key/value pairs based on the hash code of the key. Key will be used to acce...