Friday, September 26, 2014

NonActionAttribute in MVC

NonActionAttribute   represent that an attribute that is used to indicate that a controller method is not an action method. By default, the MVC framework treats all public methods of a controller class as action methods. If your controller class contains a public method and you do not want it to be an action method, you must mark that method with the NonActionAttribute attribute.  The following example  is given below
  [NonAction]
        public List<string> GetData()
        {
            List<string> item = new List<string>();
            item.Add("dd");
            return item;
        }
The above the controller method we have specify the   [NonAction] attribute. So we have restricted the access to non action method of controller.

No comments:

Post a Comment

http://blogsiteslist.com