ASP.NET Identity Manager Error: Error while trying to create a controller of type MetaController (without constructor without parameters)

The ThinkTecture IdentityManager works for me, but now when you go to '/ idm / url, I get the error message:

An error occurred when trying to create a controller of type 'MetaController'. Make sure that the controller has a parameterless public constructor.

The error was mentioned in a comment in https://stackoverflow.com/a/1673249/ ... but no solution to this problem was given. enter image description here

+4
source share
2 answers

In formulating this question, I also found a solution to an issue of the IdentityManager GitHub repo. I had to change the constructor for ApplicationUserManagerin IdentityConfig.cs:

public ApplicationUserManager(IUserStore<ApplicationUser> store): base(store) {}

in

public ApplicationUserManager(ApplicationUserStore store): base(store) {}

And a similar type change in the function is a Createlittle lower to get compilation.

ApplicationUserStore .

public class ApplicationUserStore: UserStore<ApplicationUser>
{
    public ApplicationUserStore(ApplicationDbContext ctx): base(ctx) {}
}

Startup.cs ApplicationRoleStore.

+6

, , DI

    public static void ConfigureMyCustomIdentityManagerService(this IdentityManagerServiceFactory factory, string connectionString)
    {
        factory.Register(new Registration<UserManager<User, Guid>>(x => new MyCustomUserManager(new MsSqlUserStore<User>(connectionString))));
        factory.Register(new Registration<RoleManager<Role, Guid>>(x => new RoleManager<Role, Guid>(new MsSqlRoleStore<Role>(connectionString))));

        factory.IdentityManagerService = new Registration<IIdentityManagerService, AspNetIdentityManagerService<User, Guid, Role, Guid>>();
    }
+1

Source: https://habr.com/ru/post/1613246/


All Articles