OrchardControllerFactory Error

Topics: Customizing Orchard, Writing themes
May 15, 2011 at 2:34 AM

  I often get this error message:

The IControllerFactory 'Orchard.Mvc.OrchardControllerFactory' did not return a controller for the name 'TheAdmin'. 

How are most people handling this?  I have a custom theme installed if it help.

May 16, 2011 at 7:15 PM

I don't remember ever seeing this. Does it reproduce without that custom theme? Did you identify any specific conditions under which this happens? Do you have a stack trace?

May 17, 2011 at 1:06 AM

  Hi Bertrand,

  I just reproduced this error without a custom theme as well.  All I did was click on "Dashboard" and got the following stack trace. It happens quite frequently when I'm navigating the dashboard.

   at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<BeginProcessRequest>b__2()
   at System.Web.Mvc.SecurityUtil.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a()
   at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
   at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust[TResult](Func`1 func)
   at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
   at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
   at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
   at Orchard.Mvc.Routes.ShellRoute.HttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

May 17, 2011 at 3:29 AM

What modules are enabled?

May 18, 2011 at 2:01 AM
  • Blogs
  • A custom module I'm writing for learning
  • Url Alternates
  • Shape Tracing
  • code generation
  • one of the imaging modules from the gallery
May 18, 2011 at 4:07 AM

Can you try to disable your module and the imaging one? (from the command line as you obviously couldn't get to the modules screen)

May 18, 2011 at 4:56 AM

It turns out it's my module that's causing this apparently.  I disabled all other modules except mine and I get the error.  I disabled them all and I stopped getting the error.  My module makes no reference to "TheAdmin" though.  It was created via the console if that's relevant.

May 18, 2011 at 5:04 AM

Your module is probably overriding something it shouldn't, preventing TheAdmin to be found.

May 20, 2011 at 12:00 AM

I'm still struggling to see what I have in my module that could be causing this.  Do you know what could possibly be overridden?

May 20, 2011 at 12:01 AM


May 20, 2011 at 12:11 AM

My routes don't make any mention of "TheAdmin" but I'll comment each route one-by-one just in case this is it.  Also, is AdminFilter.cs relevant to this issue?  It makes a reference to "TheAdmin".

May 20, 2011 at 12:17 AM

No they don't, that's not the problem. What I think is happening is that MVC can't build a route for a specific action because it has been shadowed by another route that is equivalent but does *not* point to TheAdmin. So yeah, that's precisely the problem: you probably have a route that *doesn't* point to TheAdmin and replaces one that did.

May 20, 2011 at 1:24 PM

As a head's up, I'm seeing the exact same thing when attached with the debugger on my development sites.  When browsing the admin, I get the "TheAdmin" controller error on each request.  It also started once I created my own module.  Interestingly, I'm also getting the "missing controller" error on the custom theme I'm working on developing (the error states that it's looking for a controller named the same as my theme when browsing the public portion of the site with the debugger attached). 

I don't have any routes in my new theme, so I'm not sure how I could be stepping on any routes.  I have not been able to nail down a reliable, reproducible test case just yet.  Anyone have any additional debugging steps I could take?


May 20, 2011 at 2:04 PM

One thing that occurs to me, is did you base your module on another one? I'm wondering if you have any namespaces that you haven't altered to your own. I've seen odd problems crop up due to namespace conflicts between modules. Just a possibility.

May 23, 2011 at 6:45 PM

This is the error that comes up when debugging and there's (what should be) a 404 in the admin.  For example, I accidentally put 'builder.AddImageSet("mymodule")' in the AdminMenu stuff, which made Orchard look for a specific CSS file that didn't exist. If I was debugging, I would get the exception you have referred to in this thread.

Jun 2, 2011 at 12:15 AM

Yep, ldhertert, that was it.  Thank you much.  Exactly what is AddImageSet's purpose?

Jun 9, 2011 at 6:15 PM

Good call ldhertert.  That was my problem too.  I was missing a css file that the system was looking for in a module that I created.  Thanks!