A controller class is a class just like other classes. It is
not necessary to derive this class from a special class or implement an interface
for it, but it is recommended to derive a controller class from System.Web.MVC.Controller
base class for ease of development and getting the benefits of this base class
in your development.
Controller class provides some tools that can assist you on
developing your ASP.NET MVC applications and I do not think any developer wants
to avoid using it. Controller class is applied to all project and file item
templates in Visual Studio and whenever you create a new MVC controller class
in Visual Studio this class appears in your code.
You can add a new MVC controller class file in the Add New
Item dialog as is shown in Figure 1.
Listing 1 shows the default code for a controller class that
I named SampleController.
public class SampleController : Controller
public void Index()
//Add action logic here
As you see, there is a reference to System.Web.Mvc
namespace which comes to your machine after installing the ASP.NET 3.5
extensions and the class is also derived from the Controller