Umbraco-CMS: V8 - Default controller - Unable to resolve type on startup

I created a Default Controller as described on Umbraco documentation, the calss is named CustomController, website running on Umbraco 8.5.3 on Umbraco Cloud. Often on system startup, the Composing class fails to set the default controller, with the error “Unable to resolve type: CustomController”

The website shows that error on every page, as it is unable to start. Restarting the application “fixes” the issue, but the issue may happen again on the next deploy / restart

Umbraco version

I am seeing this issue on Umbraco version: 8.5.3

Reproduction

Bug summary

  • Using a custom default controller may lead to error: “Unable to resolve type: CustomController”

IUserComposer class:

public class CmsSetupComposer : IUserComposer
{
    public void Compose(Composition composition)
    {
        composition.SetDefaultRenderMvcController<CustomController>();
    }
}

Default Controller class:

public class CustomController : Umbraco.Web.Mvc.RenderMvcController
{
    private readonly IScopeProvider scopeProvider;

    public CustomController(IScopeProvider scopeProvider)
    {
        this.scopeProvider = scopeProvider;
    }
    public override ActionResult Index(ContentModel model)
    {
        try
        {
            using (var scope = scopeProvider.CreateScope(autoComplete: true))
            {
                Authentication.EmailAuth.EmailLogin.LoginByUrl(scope);
            }
        }
        catch (Exception ex)
        {
            USwissKnife.Tools.ManageExceptionAsString(this.GetType(), ex);
        }
        return base.Index(model);
    }
}

Full error message:

screenshot-20200224-091544

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

Ah this is a good point @jamiepollock! So @jpinto3488 do you have any dependencies in your CustomController that need to be injected through LightInject? In your sample code there is nothing custom but of course if you have anything that your controller relies on that’s not registered then you will get errors.