Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>UPDATE</strong> The reason this is happening is that when an image is specified in a css file, and that image is missing the routing framework tries to map the url to a controller. Ignoring the routes as listed below will prevent the error from happening, but I decided not to implement it because it's a nice way of being notified that you have a missing resource.</p> <p>You can see a detailed explanation along with examples of setting up dependency injection using Structure Map <a href="http://www.codingcontext.com/post/ControllerType-Is-Null-When-Creating-A-Custom-ControllerFactory.aspx" rel="noreferrer">here</a>.</p> <p>I was having the same issue and I think I figured it out. For whatever reason whenever you try to provide your own Controller Factory you need to add a couple of additional IgnoreRoute definitions. The first thing I would do is add this line to your GetControllerInstance method:</p> <pre><code>if(controllerType == null) return base.GetControllerInstance(controllerType) </code></pre> <p>This will at least give you more information in the error message as to what the request is that is causing the controllerType to be null. In my particular case I had a background image in my css file set like this:</p> <pre><code>background: url(img/logo.gif); </code></pre> <p>So what happens is the routing is looking for a controller called "img" and an action that takes logo.gif or something along those lines. That's obviously not the correct behavior. </p> <p>After some digging I realized I needed to add an IgnoreRoute definition to my Global.asax file that would ignore anything in the "content" directory of my site like this:</p> <pre><code>routes.IgnoreRoute("{Content}/{*pathInfo}"); </code></pre> <p>I'm still not sure why you don't need to do this with the default ControllerFactory, but nonetheless it works.</p> <p>You'll probably run into the same issue with favicon.ico. Particularly if you using google crhome. You'll need to add this as well:</p> <pre><code>routes.IgnoreRoute("{*favicon}", new {favicon=@"(.*/)?favicon.ico(/.*)?"}) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload