Web Application Component Toolkit

Page Controller

A Page Controller is one object or file declaration designed to handle the request for one logical web page or action.

With a simple mapping between a page request (URL) and files, this is the default pattern for scripting solutions (PHP, ASP, JSP). A single file handles the request for a specific page. This simple mechanism mirrors how static web pages are handled.

Scripting solutions provide a poor separation between the view and the controller when implementing a Model View Controller architecture. This can make testing and reuse difficult. Also See Template View for separating the View from other application logic.

The primary responsibility of the page controller as part of Model View Controller is to process input and coordinate the model and the view. The page controller extracts information from the web server request and invoke an action on the model or calls a view based on that information. Page controller is distinguished from a Front Controller in that the page controller operates on only a single logical page, where a Front Controller performs this functions for a set of logical pages.

Page Controllers are useful on web sites with static navigation structures.

Base Controller

When multiple page controllers share duplicate logic, a common practice is to move that logic to a base page controller which each page controller can inherit from. This is one way of implementing Centralized Request Logic.

ASP.NET provides a special mechanism for implementing base controllers in scripts, called Code Behind.

When the base controller class begins to have special case logic in it for types of requests, it might be a good idea to consider a Front Controller instead.

Page Controllers in Modern Web Applications

The Page Controller pattern reflects one of the basic ways web applications respond to requests. A particular URL or application action is connected to code that handles the request, performs the necessary work, and returns a response to the user.

Modern frameworks may organize this differently through routes, controllers, request handlers, or server-side components, but the basic idea remains familiar. A specific part of the application is responsible for coordinating the work required for a particular page or action.

This relationship between URLs, requests, application logic, and responses is part of the wider architecture of web applications. Different applications may use a Page Controller, a Front Controller, or other approaches depending on their size and the way requests are organized.

Modern browser-based applications can extend this idea further. Some actions may involve a request to a server, while others can be handled directly in the browser. An online application can therefore combine server-side request handling with client-side interfaces and processing.