Error trying to update to using SignInManager in Identity 2.0

℡╲_俬逩灬. 提交于 2020-01-06 21:28:05

问题


I am trying to update my login feature to using this line:

var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);

However I get the following error:

Error   1   Using the generic type 'Microsoft.AspNet.Identity.Owin.SignInManager<TUser,TKey>' requires 2 type arguments

Before this I had to install a few nuget packages so I think something merely has been missed somewhere, but this is way out my my league! Any help would be hugely appreciated,

Thanks


回答1:


You need to supply the types as well. Like this:

var result = await SignInManager.PasswordSignInAsync<IdentityUser, string>(model.Email, model.Password, model.RememberMe, shouldLockout: false);

IdentityUser may be ApplicationUser if you've been following the example code.

Also, The examples you're looking at are based on the microsoft.aspnet.identity.samples nuget package. This would put an ApplicationSignInManager in the identityConfig.cs which extends SignInManager<ApplicationUser, string> and then a public SignInManager property in the Accountcontroller. Its this property that the examples use - hence why it doesn't have the type requirement.



来源:https://stackoverflow.com/questions/25103900/error-trying-to-update-to-using-signinmanager-in-identity-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!