Creating a user registration API

It goes without saying that, in order to authenticate and authorize users, we need to provide some mechanism to register them to our application. ASP.NET Core makes this task easy by providing utility classes that we can use to make sure that user registration is secure. 

Open (or create, if needed) the AccountController and add to the constructor the following dependencies:

  • UserManager<User>: Provides the APIs for managing users in a persistence store
  • SignInManager<User>: Provides the APIs for user logins
  • IConfiguration: Provides the access point for the application configuration

Store each dependency in a class member. Your class should look similar to this:

[Produces("application/json")][Route("api/Account")] ...

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.