Error trying to update to using SignInManager in I

2019-09-05 07:54发布

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条回答
爷的心禁止访问
2楼-- · 2019-09-05 08:15

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.

查看更多
登录 后发表回答