Class DefaultControllerFactory
Represents the controller factory that is registered by default.
public class DefaultControllerFactory : IControllerFactory
- Inheritance
-
DefaultControllerFactory
- Implements
- Inherited Members
Constructors
DefaultControllerFactory()
Initializes a new instance of the DefaultControllerFactory class.
public DefaultControllerFactory()
DefaultControllerFactory(IControllerActivator)
Initializes a new instance of the DefaultControllerFactory class using a controller activator.
public DefaultControllerFactory(IControllerActivator controllerActivator)
Parameters
controllerActivatorIControllerActivatorAn object that implements the controller activator interface.
Methods
CreateController(RequestContext, string)
Creates the specified controller by using the specified request context.
public virtual IController CreateController(RequestContext requestContext, string controllerName)
Parameters
requestContextRequestContextThe context of the HTTP request, which includes the HTTP context and route data.
controllerNamestringThe name of the controller.
Returns
- IController
The controller.
Exceptions
- ArgumentNullException
The
requestContextparameter is null.- ArgumentException
The
controllerNameparameter is null or empty.
GetControllerInstance(RequestContext, Type)
Retrieves the controller instance for the specified request context and controller type.
protected virtual IController GetControllerInstance(RequestContext requestContext, Type controllerType)
Parameters
requestContextRequestContextThe context of the HTTP request, which includes the HTTP context and route data.
controllerTypeTypeThe type of the controller.
Returns
- IController
The controller instance.
Exceptions
- System.Web.HttpException
controllerTypeis null.- ArgumentException
controllerTypecannot be assigned.- InvalidOperationException
An instance of
controllerTypecannot be created.
GetControllerSessionBehavior(RequestContext, Type)
Returns the controller's session behavior.
protected virtual SessionStateBehavior GetControllerSessionBehavior(RequestContext requestContext, Type controllerType)
Parameters
requestContextRequestContextThe request context.
controllerTypeTypeThe type of the controller.
Returns
- SessionStateBehavior
The controller's session behavior.
GetControllerType(RequestContext, string)
Retrieves the controller type for the specified name and request context.
protected virtual Type GetControllerType(RequestContext requestContext, string controllerName)
Parameters
requestContextRequestContextThe context of the HTTP request, which includes the HTTP context and route data.
controllerNamestringThe name of the controller.
Returns
- Type
The controller type.
ReleaseController(IController)
Releases the specified controller.
public virtual void ReleaseController(IController controller)
Parameters
controllerIControllerThe controller to release.