2

I just updated all my identity nuget packages so that I can use

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

but VS can't find it. It only finds SingInManager<> with intellisense. There is no SignInManager.PasswordSignInAsync(...). I even did a go to definition on SignInManager and looked at the source code in the library and it doesn't show a PasswordSignInAsync with any email parameter, jsut a username. I looked at the version at the top of the file and it shows

region Assembly Microsoft.AspNet.Identity.Owin.dll, v2.0.0.0

C:\TFS\GiftExchange\packages\Microsoft.AspNet.Identity.Owin.2.1.0\lib\net45\Microsoft.AspNet.Identity.Owin.dll

So I know I have the correct library right?

enter image description here

and even that seems to be broken. I'm trying to follow the code found here

http://blogs.msdn.com/b/webdev/archive/2014/08/05/announcing-rtm-of-asp-net-identity-2-1-0.aspx

I've updated all my nuget packages and checked them and they all are downloaded with their dependencies downloaded as well. Am I missing something to get SignInManager.PasswordSignInAsync?

chuckd
  • 13,460
  • 29
  • 152
  • 331
  • please take a look at [using email instead of username in asp.net identity ](http://stackoverflow.com/questions/19758575/asp-net-identity-use-email-instead-of-user-name) – aliadly Sep 11 '16 at 23:39

1 Answers1

3

Nothing wrong with packages you have downloaded, actually you can't use it that way.

First create ApplicationUserManager class inheriting UserManager<YourApplicationUser>

Then create ApplicationSignInManager class by inheriting SignInManager<YourApplicationUser, string>

Then you can user below code to get owin context for passworSignIn

public ApplicationSignInManager SignInManager
        {
            get
            {
                return _signInManager ?? HttpContext.GetOwinContext().Get<ApplicationSignInManager>();
            }
            private set 
            { 
                _signInManager = value; 
            }
        }

Then you can call

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

Create new project using visual studio using individual accounts template, then you can easily get idea about the ApplicationUserManagerand ApplicationSignInManager class. Both classes can be found on IdentityConfig.cs class under App_Start folder.

DSR
  • 4,588
  • 29
  • 28
  • I followed the code here http://stackoverflow.com/questions/27186310/applicationsigninmanager-class-is-null-during-authentication-process, but this gives me a PasswordSignInAsyn where I need to pass in a model.UserName, NOT a email! I want to pass in a email, not a username to sign in like in the original link I posted. – chuckd Feb 04 '15 at 18:46
  • I just want to log in with email instead of a username, it seems like there should be an easier way to do this?? – chuckd Feb 04 '15 at 18:52
  • Actually identity framework uses username, but you need to use email as your userName if you need to achieve it that way. – DSR Feb 04 '15 at 20:06