1. 程式人生 > >InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityU

InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityU

在新建asp.net core 應用後, 添加了自定義的ApplicationDbContext 和ApplicationUser ,並添加了Identity認證後, 會出現 InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]' 錯誤。需要把相關網頁上注入的UserManager<IdentityUser> 改為UserManager<ApplicationUser> .