Non-Action Attribute in MVC
When you create an action method with public access modifier in the controller
so you can access the method through URL from the browser.
If you don't want to call a method through URL from browser then use nonaction
attribute in method
Example:
public class LearnController: Controller
{
// GET: Learn
public ActionResult Index()
{
return View();
}
[NonAction]
public ActionResult NonActionMethod()
{
return View();
}
}
Comments
Post a Comment