I've configured structuremap successfully but every page search for a controller with name "scripts"
public class StructureMapControllerFactory 开发者_高级运维: DefaultControllerFactory
{
public override IController CreateController(RequestContext context, string controllerName)
{
Type controllerType = base.GetControllerType(context, controllerName);
return ObjectFactory.GetInstance(controllerType) as IController;
}
}
It happens because the parameter string ControllerName comes everytime with the string "scripts"
The problem might be that the script requests are being handled by the routing engine. You have to configure your routes so that the scripts, favicon, images, etc are ignored by the routing engine.
Try overriding GetControllerInstance
instead of CreateController
:
public class StructureMapControllerFactory : DefaultControllerFactory
{
protected override IController GetControllerInstance(Type controllerType)
{
return (IController)ObjectFactory.GetInstance(controllerType);
}
}
精彩评论