views:

31

answers:

2

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"

A: 

Try overriding GetControllerInstance instead of CreateController:

public class StructureMapControllerFactory : DefaultControllerFactory
{
    protected override IController GetControllerInstance(Type controllerType)
    {
        return (IController)ObjectFactory.GetInstance(controllerType);
    }
}
Darin Dimitrov
+1  A: 

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.

uvita