Unable to access CreateAsync in User Manager

后端 未结 3 1099
情话喂你
情话喂你 2020-12-17 02:53

I\'m trying to use the new Asp.Net Identity system. I\'ve searched this in asp.net site and able to find a tutorial here.

I\'ve created Register

相关标签:
3条回答
  • 2020-12-17 03:51

    Have you referenced "Microsoft.AspNet.Identity.Core, Version=2.0.0.0"?

    Microsoft ASP.NET Identity Core 2.0.0

    Update 1 I've just looked back at some code where I have done this, and it looks like I ended up using the non-async version:

    var result = userManager.Create(user, password);
    

    Although this doesn't answer your specific question, it may help.

    Update 2 Check you have the following using statements:

    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using Microsoft.Owin.Security;
    
    0 讨论(0)
  • 2020-12-17 03:51

    So, at the beginning just declared a property as

     public UserManager<ApplicationUser> UserManager { get{return _userManager;} private set{} }
    

    And

      private AppUserManager _userManager 
    {
      get { return HttpContext.GetOwinContext().GetUserManager<AppUserManager>();}
    }
    
    0 讨论(0)
  • 2020-12-17 03:52
    var result = await UserManager.CreateAsync(user, register.Password);
    

    The UserManager in the above statement is not a Class as I've expected. Its a property of type UserManager<ApplicationUser>.

    So, at the beginning just declared a property as

    public UserManager<ApplicationUser> UserManager { get; private set; }
    

    And now I can use the Async version for creating users. The following statement works.

    var result = await UserManager.CreateAsync(user, register.Password);
    
    0 讨论(0)
提交回复
热议问题