/// <summary> /// Initializes the controller context for creating controllers dynamically /// </summary> /// <param name="httpContext"></param> /// <param name="controller"></param> /// <param name="action"></param> /// <param name="area"></param> public void InitContext(System.Web.HttpContext httpContext, string controller, string action, string area, TempDataDictionary tempData) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } if (string.IsNullOrEmpty(controller)) { throw new ArgumentNullException("controller"); } if (string.IsNullOrEmpty(action)) { throw new ArgumentNullException("action"); } if (this.ControllerContext == null) { System.Web.Routing.RouteData routeData = new RouteData(); routeData.Area(area ?? ""); routeData.Controller(controller); routeData.Action(action); this.ControllerContext = new ControllerContext(new HttpContextWrapper(System.Web.HttpContext.Current), routeData, this); if (tempData != null) { this.TempData = tempData; } } }