.NET 7 Web API 🔒 JWT Authentication and role-based Authorization

preview_player
Показать описание
#aspdotnetcore #dotnet #jwt
A step-by-step guide to user authentication using ASP.NET Core 7, Identity, MSSQL
Create a minimal API project in Visual Studio 2022.

🚀 Table of Contents:
✅ 1. Create Project: Using Visual Studio 2022
- API Project, Dotnet 7.0, and a class library project for data connectivity and migration

✅ 2. Install the Required Packages
dotnet add package Microsoft.AspNetCore.Authentication.JwtBearer --version 7.0.4
dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore --version 7.0.4
dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 7.0.4
dotnet add package Microsoft.EntityFrameworkCore.Tools --version 7.0.4

✅ 4. Create models and complete ApplicationDbContext class
✅ 6. Database Migration
dotnet ef migrations add InitialCreate
dotnet ef database update
-- using PMC
PM: add-migration initcreate
PM: update-database

✅ 7. Create Auth Controller
✅ 8. Crete Auth Service

✅ 9. Test API using postman
✅ 10. Deploy to IIS
✅ 11. Test API from IIS hosting

🚀 My Profile:

✅ Business ERP Solution/Product/POS/Company Management:

✅ School/College/University Management ERP:

✅ Dashboard Template | ASP.NET Core MVC Web Starter Kit

✅ Advance POS System with Stock Manager | ASP.NET Core | EF Core | .NET Core 6.0:

✅ Asset Management System with Barcode | ASP.NET Core | EF Core | .NET Core 6.0:

✅ Advanced Files & Users Management | ASP.NET Core | EF Core | .NET Core | MSSQL | MySQL:

✅ Hospital and Pharmacy Management System | ASP.NET Core | EF Core:

✅ Inventory and User Management System:

✅ Invoice Gen(Invoice Generation and Management) using .Net Core and EF:

✅ Complaint | Issue | Helpdesk Ticket | My Ticket HelpDesk Support System | ASP.NET Core | EF Core:

✅ User Management:

✅ ASP.NET Core CRUD Operation Using Dot Net 6.0 | MVC| MSSQL | MySQL | EF Core Code First | jQuery

✅ ASP.NET Core full CRUD with .NET 5 | MSSQL/MySQL | EF code first:

✅ Staff | Employee Leave Management System

✅ Library Management System | ASP.NET Core | MSSQL | Code First
Рекомендации по теме
Комментарии
Автор

Awesome sir. Let share to my Friends thanks....

codingislife
Автор

please help me sir, why always get response 400 in swagger when i try login and registration, and in user list i aways get error respone 401

nugroho
Автор

excusme sir, may you help me please ?

in swagger when Exacute always " Error: response status is 400 " ini Login and Registration,
and in userlist "Error: response status is 401"


please help me :(

nugroho
Автор

thank you for this video,
please help me sir why always get response 400 in swagger when i try login and registration, and in user list i aways get error respone 401

mohamedhcini-bn
Автор

Can you demo using sql commad or store procedure?

nangdalet
Автор

By default it is taking admin as role. How to change that

SomethingSpiritual
Автор

Can you pls stop the music your teaching good only

prakashm
Автор

There's something wrong in

in the method:
public async Task<(int, string)> Registration(Registration model, string role)

when going thru this line while debugging:
var userExists = await

I always get this Exception:
"Invalid column name 'Firstname'"

I followed each one the video's instructions thoroughly, and still, it's not working for me..

I'm frustrated since I spent valuable time following this vid, only to get a dead end.

The only difference I got was that I used the MS SQL LocalDB..

You should verify all your code man and not, before launching a video.

StephenArpad