How to inject webapi AccountController in WebApi

后端 未结 1 1395
梦谈多话
梦谈多话 2020-12-22 03:44

I have default constuctor and constructor with params like here:

public class AccountController : ApiController
{
    private const string LocalLoginProvider         


        
1条回答
  •  时光取名叫无心
    2020-12-22 04:13

    You should remove the parameterless constructor.

    Next, you need to configure a custom dependency resolver, which will basically wrap your Unity container. See http://www.asp.net/web-api/overview/advanced/dependency-injection

    After that, make sure that you register all your types. For example, I don't see a registration for ApplicationUserManager. You are registering UserManager but not ApplicationUserManager, which is what the IoC container will attempt to resolve.

    0 讨论(0)
提交回复
热议问题