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:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace ControllerApplication.Controllers
- {
- public class TestingController : Controller
- {
-
-
- [NonAction]
- public ActionResult Index()
- {
- return View();
- }
- }
- }