IController in ASP.NET MVC

Every Controller in ASP.NET MVC is extended from the Controller abstract class which in turn implements the IController interface. The IController interface is defined in the System.Web.Mvc namespace of the .NET Framework.

IController in ASP.NET MVC

The IController interface contains the method Execute which is called when the user enter the URL which involves the implemented controller class.

#region Assembly System.Web.Mvc.dll, v4.0.0.0

// C:\temp\MvcApplication1\packages\Microsoft.AspNet.Mvc.4.0.20710.0\lib\net40\System.Web.Mvc.dll

#endregion

using System;

using System.Web.Routing;

namespace System.Web.Mvc

{

// Summary:

// Defines the methods that are required for a controller.

public interface IController

{

// Summary:

// Executes the specified request context.

//

// Parameters:

// requestContext:

// The request context.

void Execute(RequestContext requestContext);

}

}

The controller classes that you create can implement IController but you might have to do little more work when using this way. For example, you might have to implement the method Execute and write the code on what actions to be taken on request.

There is a better way of doing it using the Controller class which will be discussed in the next article.

%d bloggers like this: