Controller

What Does Controller Mean?

A controller is a program component that serves as a mediator between a user and application and handles business-related tasks triggered in ASP.NET pages. A controller is used for scripting exposed and middle-tier endpoints for expected user actions and results.

Advertisements

Techopedia Explains Controller

A controller serves different roles in ASP.NET Web Form and Model-View-Controller (MVC) architectural designs. ASP.NET Web Forms are built on a sequentially-phased model, from parsing incoming requests to generating HTML pages based on ASP.NET source file templates. An ASP.NET Web Form controller handles all business tasks triggered by the page, and the event handler collects server control input data that is packaged for the controller. Because they are tightly coupled, flexibility between the controller and user interface (UI) is hindered.

In MVC architectural patterns, a controller operates in a central role with different mechanics. The controller class is a plain class with some public methods. Each method has a one-to-one link with a possible user action, ranging from the click of a button to another trigger. The controller class methods process input data, execute application logic and determine view. An action filter is used to decorate the controller’s methods with pre and post-action behavior, as follows:

public class Controller A : Controller {
public ActionResult A(){
//execute some application logic and then yield to the view engine.
return this.View(“A”);
}
}

The controller has a layered structure that starts with the IController interface at the bottom, followed by the controller base class, controller class, other interfaces and, finally, the user-defined controller class responsible for total top interactivity.

Controller classes follow an inheritance hierarchy, where preceding class methods must be implemented by subsequent classes. For example, controller base class methods must be recognized to allow overriding by the derived controller classes and functionality implementation.

Controller activities may be summarized as follows:

  • Gathering input
  • Executing the request-related action method
  • Preparing view data
  • Triggering view refreshing
Advertisements

Related Terms

Latest DevOps Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…