public IHttpController Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) { IHttpController httpController = null; string controllerName = controllerDescriptor.ControllerName.IsNotNullOrEmpty() ? controllerDescriptor.ControllerName : controllerDescriptor.ControllerType.Name; try { httpController = Container.Instance.Resolve(controllerDescriptor.ControllerType) as IHttpController; if (httpController.IsNull()) { httpController = Container.Instance.Resolve(controllerDescriptor.ControllerType, controllerDescriptor.ControllerName) as IHttpController; } } catch { httpController = Container.Instance.Resolve(controllerDescriptor.ControllerType, controllerDescriptor.ControllerName) as IHttpController; } if (httpController.IsNull()) { HttpResponseUtility.ThrowHttpResponseError(HttpStatusCode.InternalServerError, controllerName + " not registered in Unity DI container", request); } return(httpController); }