简体   繁体   中英

No signinmanager class found in Identity 2.1.0

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?

在此处输入图片说明

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?

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 ApplicationUserManager and ApplicationSignInManager class. Both classes can be found on IdentityConfig.cs class under App_Start folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM