StructureMap controller factory and null controller instance in MVC

前端 未结 4 1041
不知归路
不知归路 2021-02-08 10:38

I\'m still trying to figure things out with StructureMap and one of the issues i\'m running into is my Controller Factory class blowing up when a null controller type is passed

4条回答
  •  再見小時候
    2021-02-08 11:07

    I was having the similar problem. I believe it was HTTP requests for nonexistent images, CSS files, etc.

    We know the MVC routing first looks to see if the requested file physically exists. If it doesn't then the URL gets tested against the configured Routes. I think the request for an image that didn't physically exist was passed to the Routing engine, and didn't match any routes, so NULL was used.

    So to fix it, use FireBug or something to watch for, and fix, broken HTTP requests. During development, I used a route like this to temporarily bypass these issues (all of my resource folders start with an underscore like _Images, _Styles, etc):

    routes.IgnoreRoute("_*");  // TODO: Remove before launch
    

    Hope this helps!

提交回复
热议问题