Authentication in ASP.Net Core — Getting Started

A step-by-step guide for user authentication in your ASP.Net Core Web Apps

ASP.Net Core Identity Framework

Identity Framework Architecture

#1 — Data Layer

#2 — Data Access Layer

#3 — Business Layer

#4 — Extensions

Enough said, time to code ..

Step #1 — Create a new .Net Core web app project

Step #2 — Add and configure ASP.Net Core Identity in the web app


Step #3 —User registration

POST request to /accounts/register{
"userName": "john",
"email": "",
"password": "&Secret99",
"confirmPassword": "&Secret99"
Successful User Registration
POST request to /accounts/register{
"userName": "johndoe",
"email": "",
"password": "&Secret99",
"confirmPassword": "&Secret99"
Failed User Registration

Step #4 — User login

.AddScheme<TOptions, THandler>(string authenticationScheme);
[Authorize(AuthenticationSchemes = "myAuth"]
public IActionResult Get()
// users are authenticated with "myAuth" scheme ..
// .. registered in the app
Successful login of the registered user
Cookies in Postman
Log in with the wrong password

Step #5 — User logout

Successful user logout


GET /accounts/details after user login
GET /accounts/details without user login

Software Engineer | Curious Mind

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store