Controller.Initialize Method
Initializes data that might not be available when the constructor is called.
Namespace: System.Web.Mvc
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
Syntax
'Declaration
Protected Overrides Sub Initialize ( _
requestContext As RequestContext _
)
protected override void Initialize(
RequestContext requestContext
)
protected:
virtual void Initialize(
RequestContext^ requestContext
) override
Parameters
- requestContext
Type: System.Web.Routing.RequestContext
The HTTP context and route data.
Remarks
This method cannot be called directly. Override this method in order to provide additional processing tasks before any ActionResult methods are called, such as setting the thread culture or assigning a custom provider for TempData objects. If you override this method, call the base control's Initialize method.
Examples
The following example shows how to override the Initialize method to provide additional processing when the controller class is instantiated.
protected override void Initialize( RequestContext rc) {
base.Initialize(rc);
myCtxInit( rc.HttpContext );
MyRDinit( rc.RouteData );
}
Protected Overloads Overrides Sub Initialize(ByVal rc As RequestContext)
MyBase.Initialize(rc)
myCtxInit(rc.HttpContext)
MyRDinit(rc.RouteData)
End Sub