Search code examples
c#asp.netasp.net-mvc-5asp.net-identity

Error trying to update to using SignInManager in Identity 2.0


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


Solution

  • 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.