Created
August 18, 2010 13:51
-
-
Save jglozano/534787 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web.Mvc; | |
using System.Web.Mvc.Async; | |
public class SimpleAsyncControllerFactory : TurbineControllerFactory { | |
public SimpleAsyncControllerFactory(IServiceLocator locator) : base(locator) { | |
} | |
protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType) { | |
if (controllerType == null) { | |
// this will make sure that the MVC framework throws the corresponding | |
// exception for a non-registered controller | |
return base.GetControllerInstance(requestContext, controllerType); | |
} | |
var instance = ServiceLocator.Resolve<IController>(controllerType); | |
var controller = instance as Controller; | |
// If you inherit from controller, implement this fine work around | |
if (controller != null && !controller.IsType<IAsyncController>()) { | |
controller.ActionInvoker = GetActionInvoker(); | |
} | |
return controller; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment