concept IController in category asp.net

appears as: IController
ASP.NET MVC 4 in Action

This is an excerpt from Manning's book ASP.NET MVC 4 in Action.

The IController interface defines the most basic element of a controller—a single method called Execute that receives a RequestContext object:

The default controller implementation comes with some specific ideas about how action methods are selected, executed, and extended. This functionality comes from the Controller base class in the ASP.NET MVC framework, which is the default implementation of the IController interface.

IController is a simple interface that provides a single method, Execute(), and you could choose to implement it directly. By implementing this interface, you can still use the routing and controller factory functionality of the framework and push the rest of the framework to the side.

You can see the IController interface definition in figure 16.1.

Figure 16.1. The IController interface exposes a single method, Execute().

A second extensibility option is available that isn’t as lean as implementing IController. The framework contains a ControllerBase class that provides the most basic properties for managing ViewData and TempData. The ControllerBase class is listed in figure 16.2. It’s a pretty minimal class, but it still lets you take advantage of some concepts that are shared with the view.

Figure 16.2. The ControllerBase class provides integration with routing as well as HttpContext.

Although the interface and base class extensibility points exist in the framework, few developers and projects trade the productivity built into the framework’s controller class for the power and extra work that’s needed to implement their own IController implementation. The same goes for using the ControllerBase class. We needn’t sacrifice productivity because there are a number of extensibility points built into the Controller class. We’ll cover them next.

sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest