2014-11-03 5 views
2

이 같은 일부 종속성을 등록하는 데 문제가 있습니다.Structuremap x Asp.net Identity

No default Instance is registered and cannot be automatically determined for type 'IUserStore<ApplicationIdentityUser, Int32>' 

There is no configuration specified for IUserStore<ApplicationIdentityUser, Int32> 


1.) new UserManager`2(*Default of IUserStore<ApplicationIdentityUser, Int32>*) 
2.) UserManager<ApplicationIdentityUser, Int32> 
3.) Instance of UserManager<ApplicationIdentityUser, Int32> 
4.) new ApplicationUserManager(*Default of UserManager<ApplicationIdentityUser, Int32>*, *Default of IAuthenticationManager*) 
5.) MyClinic.Infra.Data.Identity.ApplicationUserManager 
6.) Instance of MyClinic.Core.Identity.IApplicationUserManager (MyClinic.Infra.Data.Identity.ApplicationUserManager) 
7.) new AccountController(*Default of IApplicationUserManager*) 
8.) MyClinic.Web.Controllers.AccountController 
9.) Instance of MyClinic.Web.Controllers.AccountController 
10.) Container.GetInstance(MyClinic.Web.Controllers.AccountController) 

누군가 나를 도울 수 있습니까?

내 계정 컨트롤러는 다음과 같습니다

public class AccountController : Controller 
{ 
    private IApplicationUserManager _userManager; 
    public AccountController(IApplicationUserManager userManager) 
    { 
     _userManager = userManager; 
    } 
} 

내 응용 프로그램의 사용자 관리자 :

public class ApplicationUserManager : IApplicationUserManager 
{ 
    private readonly UserManager<ApplicationIdentityUser, int> _userManager; 
    private readonly IAuthenticationManager _authenticationManager; 
    private bool _disposed; 

    public ApplicationUserManager(UserManager<ApplicationIdentityUser, int> userManager, IAuthenticationManager authenticationManager) 
    { 
     _userManager = userManager; 
     _authenticationManager = authenticationManager; 
    } 
} 
+0

이 질문에 다른 변화가있다 HttpContext.Current에 표시 얻을

Microsoft.Owin.Host.SystemWeb 

패키지를 설치해야합니다. 도움이 될 것입니다. http://stackoverflow.com/a/27244289/351204 –

답변

15

당신은 당신의 structuremap 컨테이너에 다음 Asp.net ID로 작동하도록 추가해야합니다.

For<IUserStore<ApplicationUser>>().Use<UserStore<ApplicationUser>>(); 
For<DbContext>().Use(() => new ApplicationDbContext()); 
For<IAuthenticationManager>().Use(() => HttpContext.Current.GetOwinContext().Authentication); 

는 또한, 당신은 확장 메서드 GetOwinContext은()

+0

덕분에 도움이되었습니다. – SHM