Prevent Controller Method From Being Invoked

Controller in ASP.NET MVC is a class that inherits from the base class System.Web.Mvc.Controller. Any public method exposed by a controller is exposed as a controller action. If you want to prevent a public controller method from being invoked, you can put the "NonAction" attribute over the method name. By default Index() action is the default action that is invoked on a controller on when no explicit action is mentioned.

For example:   
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.Mvc;  
  6. namespace ControllerApplication.Controllers  
  7. {  
  8. public class TestingController : Controller  
  9. {  
  10. //  
  11. // GET: /Testing/  
  12. [NonAction]  
  13. public ActionResult Index()  
  14. {  
  15. return View();  
  16. }  
  17. }  
  18. }