Skip to main content
2 of 2
Commonmark migration

There are a couple of potential issues here:

  • Set the controller name to the fully qualified class name, e.g MyProject.Controllers.SomeController, MyProject
  • Make sure the action name does not have the / in, it should just be Index
  • It looks like you have not registered your controller with the IoC container. Sitecore 8.2 introduced a lot of new Dependency Injection features. But this meant that you would now have to register your controller with the container for Sitecore to be able to create it.

Registering your Controller

The easiest way to do this would be to create a Configurator class that implements IServicesConfigurator, and register your controller in there. Here is an example

using Microsoft.Extensions.DependencyInjection;
using Sitecore.DependencyInjection;

namespace MyProject
{
    public class Configurator: IServicesConfigurator
    {
        public void Configure(IServiceCollection serviceCollection)
        {
            serviceCollection.AddTransient<MyController>();
        }
    }
}

Then you have to create a patch include file that will tell Sitecore to use that Configurator. Here is an example of that:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <services>
            <configurator type="MyProject.Configurator, MyProject" />
        </services>
    </sitecore>
</configuration>

Once you have that setup, Sitecore will now know how to create your controller correctly.

Richard Seal
  • 20.8k
  • 5
  • 44
  • 79