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
controllerActivator
IControllerActivatorAn 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
requestContext
RequestContextThe context of the HTTP request, which includes the HTTP context and route data.
controllerName
stringThe name of the controller.
Returns
- IController
The controller.
Exceptions
- ArgumentNullException
The
requestContext
parameter is null.- ArgumentException
The
controllerName
parameter 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
requestContext
RequestContextThe context of the HTTP request, which includes the HTTP context and route data.
controllerType
TypeThe type of the controller.
Returns
- IController
The controller instance.
Exceptions
- System.Web.HttpException
controllerType
is null.- ArgumentException
controllerType
cannot be assigned.- InvalidOperationException
An instance of
controllerType
cannot be created.
GetControllerSessionBehavior(RequestContext, Type)
Returns the controller's session behavior.
protected virtual SessionStateBehavior GetControllerSessionBehavior(RequestContext requestContext, Type controllerType)
Parameters
requestContext
RequestContextThe request context.
controllerType
TypeThe 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
requestContext
RequestContextThe context of the HTTP request, which includes the HTTP context and route data.
controllerName
stringThe name of the controller.
Returns
- Type
The controller type.
ReleaseController(IController)
Releases the specified controller.
public virtual void ReleaseController(IController controller)
Parameters
controller
IControllerThe controller to release.