Learn how authentication works in ASP.NET by starting from an empty template and building your own authentication system! In this tutorial, we’ll cover key steps such as creating the project, configuring Program.cs, adding controllers, creating a mock user manager, and implementing cookie authentication. You’ll also learn about authorization policies, testing authentication, and handling logout functionality.
Whether you’re new to ASP.NET or looking to deepen your understanding of authentication mechanisms, this step-by-step guide has you covered. Let’s build it together!
----
💬 Did you like this video? Let us know in the comments below!
✅ Click here to subscribe to Skill Foundry now!
/ @skillfoundryio
👩💻 Join Our Coding Community on Discord!
Connect with peers, talk about tech, and share your learning journey.
Join here: / discord
📍 Like the Channel? Sign up for the Newsletter!
https://newsletter.skillfoundry.io/
💥 Learn to Code the Right Way! Our full-stack C# developer pathway provides over 700 learner hours of effort and rigor with over 80 practice projects, 150 lessons, and over a dozen capstone projects that challenge you to design and build applications from scratch.
https://www.skillfoundry.io/
📬 Contact us anytime!
[email protected]
---------------
Welcome to the official YouTube channel of Skill Foundry! With over 20 years of professional experience, Eric and the team deliver unbiased information and advice to beginners and early career developer professionals.
Learn to code the right way!
We believe that highly technical skills are learned best with a combination of real subject matter experts, learning science professionals, well written curriculum and projects, compassionate mentorship, and an enthusiastic community.
Our team has crafted and delivered technical training for over a decade, creating curriculums for Fortune 500 companies, universities, and coding bootcamps across the globe. This rigorous curriculum is now available direct to individuals for the first time.
So, hit the subscribe button and turn on the notification bell so you won't miss any new videos! 🔔
---------------
0:00 Introduction
0:35 Starting with the Empty template for learning
01:20 Topics we will cover
02:18 Creating the project
03:33 Configuring Program.cs
05:50 Adding ViewImports
07:10 Adding the Home controller
08:40 Creating a mock user manager
16:20 Using the User property to detect authentication
21:25 Creating a cookie name
22:36 Configuring Program.cs for cookie authentication
27:20 Adding an admin claim policy
29:41 Adding an auth controller with login actions
33:36 Using HttpContext.SignInAsync to create the authorization cookie
36:54 The difference between identity and principal
39:27 Testing authentication and viewing claims
40:45 Examining the cookie in browser dev tools
42:47 Using the [Authorize] attribute
46:03 Authorizing by policy
48:28 Adding a route for forbidden errors
50:26 Persisting the cookie
52:55 Adding logout functionality
----
#SkillFoundry #codingcourses #codingforbeginners #coding #programmingtutorial
---
Common Questions
What is ASP.NET authentication, and how does it work?
How do I configure cookie authentication in ASP.NET Core?
What’s the difference between identity and principal in ASP.NET?
How can I create a custom authentication system in ASP.NET Core?
What are the best practices for handling claims and policies in ASP.NET Core?
How do I persist authentication cookies in ASP.NET?
How can I implement logout functionality in an ASP.NET Core project?
What is the role of the [Authorize] attribute in ASP.NET Core?
How do I test authentication and view claims in an ASP.NET Core project?
What tools can I use to examine cookies in browser developer tools?