Structuremap search scripts on every page

I configured the structure structure successfully, but each page is looking for a controller named "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; } } 

This is because the ControllerName parameter string comes up every time with the string "scripts"

+4
source share
2 answers

The problem may be that the script requests are processed by the routing mechanism. You need to set up routes to scripts, icons, images, etc. Ignored by the routing engine.

+1
source

Try overriding GetControllerInstance instead of CreateController :

 public class StructureMapControllerFactory : DefaultControllerFactory { protected override IController GetControllerInstance(Type controllerType) { return (IController)ObjectFactory.GetInstance(controllerType); } } 
0
source

Source: https://habr.com/ru/post/1302617/


All Articles