Skip to content

Instantly share code, notes, and snippets.

@kevinpang
Created February 26, 2012 17:50
Show Gist options
  • Save kevinpang/1917941 to your computer and use it in GitHub Desktop.
Save kevinpang/1917941 to your computer and use it in GitHub Desktop.
StructureMapControllerFactory
public class StructureMapControllerFactory : DefaultControllerFactory
{
public override IController CreateController(RequestContext requestContext, string controllerName)
{
try
{
var controllerType = base.GetControllerType(requestContext, controllerName);
return ObjectFactory.GetInstance(controllerType) as IController;
}
catch (Exception)
{
//Use the default logic
return base.CreateController(requestContext, controllerName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment