开发者

Structuremap searching for scripts controller every page

开发者 https://www.devze.com 2022-12-21 22:37 出处:网络
I\'ve configured structuremap successfully but every page search for a controller with name \"scripts\"

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);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消