Why don't the UserManager of Identity recognize the Create method in configuration method?

Why don't the UserManager of Identity recognize the Create method in configuration method?

I am new to ASP.NET Identity and created a simple sign-in process and have registered the delegates in configuration method of IdentityConfig of my project.

I am new to ASP.NET Identity and created a simple sign-in process and have registered the delegates in configuration method of IdentityConfig of my project.

I am trying to register them but the UserManager and RoleManager classes are not recognizing the Create method.

public class IdentityConfig
{
    public void Configuration(IAppBuilder app)
    {
        app.CreatePerOwinContext<UserManager<AppUsers>>(UserManager<AppUsers>.Create);
        app.CreatePerOwinContext<RoleManager<AppRole>>(RoleManager<AppRole>.Create);

    app.CreatePerOwinContext(() =&gt; new UsersPhonesDBContext());

    app.CreatePerOwinContext&lt;RoleManager&lt;AppRole&gt;&gt;((options, context) =&gt;
        new RoleManager&lt;AppRole&gt;(
            new RoleStore&lt;AppRole&gt;(context.Get&lt;UsersPhonesDBContext&gt;())));

    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
        LoginPath = new PathString("/Home/Login"),
    });
}

}

Login Method:

public ActionResult Login()
{
    var userManager = HttpContext.GetOwinContext().GetUserManager<UserManager<AppUsers>>();
    var roleManager = HttpContext.GetOwinContext().GetUserManager<RoleManager<AppRole>>();
    var authManager = HttpContext.GetOwinContext().Authentication;

AppUsers user = userManager.FindByName("MyName");
if (user != null)
{
    var ident = userManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

    //use the instance that has been created. 
    authManager.SignIn(
        new AuthenticationProperties { IsPersistent = false }, ident);

    return Redirect(Url.Action("Index", "Rest"));
}

// AppUsers user= userManager.Find("Hunain","");
return View();

}

Update:

I wrote the class AppUserManager and method inside it:

public class AppUserManager: UserManager<AppUsers>
    {
        public AppUserManager(IUserStore<AppUsers> store): base(store)
        {
        }

    // this method is called by Owin therefore best place to configure your User Manager
    public static AppUserManager Create(
        IdentityFactoryOptions&lt;AppUserManager&gt; options, IOwinContext context)
    {
        var manager = new AppUserManager(
            new UserStore&lt;AppUsers&gt;(context.Get&lt;UsersPhonesDBContext&gt;()));

        // optionally configure your manager
        // ...

        return manager;
    }
}

Still

var manager = new AppUserManager(
                    new UserStore<AppUsers>(context.Get<UsersPhonesDBContext>()

throws error.

Value cannot be null.

My DB context class:

public class UsersPhonesDBContext: IdentityDbContext<AppUsers> { public UsersPhonesDBContext() : base("UsersPhonesDBContext") { Database.SetInitializer<UsersPhonesDBContext>(null); }

    public DbSet&lt;Users&gt; PhoneUsers { get; set; }
    public DbSet&lt;Phones&gt; Phones { get; set; }
    public DbSet&lt;Sims&gt; Sims { get; set; }
}


c-sharp asp.net

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire ASP.Net Developers

Looking to outsource your asp dot net development requirement? ASP.Net is a special feature of the DOT Net framework created by Microsoft. At [HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io"), we have a team of experienced...

Various ways of redirecting a request in Asp.Net Core

ASP.NET Core web applications often need to redirect a request to another resource based on some condition. There are multiple ways in which you can accomplish this task in ASP.NET Core MVC and Razor&#160;&#8230;

Routing in MVC - ASP.NET Core Demystified

ASP.NET Core MVC has introduced quite a few concepts that new (or new-to-ASP.NET) web developers might have some difficulty getting caught up with. My ASP.NET Core Demystified series is designed to help these developers get started building their own custom, full-fledged, working AASP.NET Core applications. In

What is the ASP.Net Machine Account on my Computer?

Some users have reported the existence of the ASP.Net machine account. In this article, I will discuss what is asp.net machine account in windows 10/7 and how to disable it, asp.net machine account password, and can I delete asp.net machine account? .NET Framework is an application on Windows that requires the installation to run several apps or games. However, when the .NET Framework is downloaded and installed, the application automatically creates an ASP NET machine account.

Add asp.net Identity in empty project

LIKE | COMMENT | SHARE | SUBSCRIBE Today, in this tutorial you will see the process of adding an ASP.NET Identity to the ASP.NET Web Application developed in...