4
Reply

What is the use of NonActionAttribute in Asp.Net MVC?

Ankit Kumar

Ankit Kumar

12y
11.9k
0
Reply

    If you decorated action method with [NonAction] attribute you can't access that through URL.We can restrict this by using private also,but in some scenarios we need public access so by decarating with [NonAction] attribute we can prevent.

    This is indicate that a controller method is not an action method.Example: [NonAction] public void IndexTest() { // Do some thing } this is very useful attribute when visibility of controller 's method cannot be changed to private.

    [NonAction]public ActionResult About(){ViewBag.Message = "Your application description page.";return View();}

    This is the action filter attribute, used to indicate this method of controller is not an action method.