Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Core Tech
Labs

Add Authentication to an Existing ASP.NET Core Wishlist Application

In this code lab, you'll start with an ASP.NET Core Wishlist application that only supports one user with one Wishlist and has no security. You will add the ability to support multiple users with their own Wishlists secured with basic authentication.

Lab platform
Lab Info
Level
Beginner
Last updated
Sep 22, 2025
Duration
3h 10m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Update ApplicationDbContext's Inheritance

    Configure the project so that authentication will be available throughout the application. ### Solution To view the solution, run git diff module1-solution <filepath>/<filename> in the Terminal, and press Enter to see the next lines of the difference. e.g. git diff module1-solution WishList/Data/ApplicationDbContext.cs

    You may also update your local file browse the files of the solution by change diff to checkout e.g. git checkout module1-solution WishList/Data/ApplicationDbContext.cs

  2. Challenge

    Create AccountController

    Create a controller named AccountController that will handle actions related to authentication. ### Solution To view the solution, run git diff module1-solution <filepath>/<filename> in the Terminal, and press Enter to see the next lines of the difference. e.g. git diff module2-solution WishList/Controllers/AccountController.cs

    You may also update your local file browse the files of the solution by change diff to checkout e.g. git checkout module2-solution WishList/Controllers/AccountController.cs

  3. Challenge

    Create RegisterViewModel Class

    Create Views, View Models, and add action methods to the AccountController to add the ability to register an account. ### Solution To view the solution, run git diff module1-solution <filepath>/<filename> in the Terminal, and press Enter to see the next lines of the difference. e.g. git diff module3-solution WishList/Models/AccountViewModels/RegisterViewModel.cs

    You may also update your local file browse the files of the solution by change diff to checkout e.g. git checkout module3-solution WishList/Models/AccountViewModels/RegisterViewModel.cs

  4. Challenge

    Create LoginViewModel

    Fully implement the ability to login and logout of an already registered user account. ### Solution To view the solution, run git diff module1-solution <filepath>/<filename> in the Terminal, and press Enter to see the next lines of the difference. e.g. git diff module3-solution WishList/Models/AccountViewModels/LoginViewModel.cs

    You may also update your local file browse the files of the solution by change diff to checkout e.g. git checkout module3-solution WishList/Models/AccountViewModels/LoginViewModel.cs

  5. Challenge

    Add Using Directives to Index View

    Update views to provide links to Login, Logout, and Register actions depending on if the user is logged in or not. ### Solution To view the solution, run git diff module1-solution <filepath>/<filename> in the Terminal, and press Enter to see the next lines of the difference. e.g. git diff module5-solution WishList/Views/Home/Index.cshtml

    You may also update your local file browse the files of the solution by change diff to checkout e.g. git checkout module5-solution WishList/Views/Home/Index.cshtml

  6. Challenge

    Add a Virtual ApplicationUser Property to Item

    Create a relationship between the Item and ApplicationUser models so operations on data happen for a single user's data. ### Solution To view the solution, run git diff module1-solution <filepath>/<filename> in the Terminal, and press Enter to see the next lines of the difference. e.g. git diff module6-solution WishList/Models/Item.cs

    You may also update your local file browse the files of the solution by change diff to checkout e.g. git checkout module6-solution WishList/Models/Item.cs

  7. Challenge

    Add Authorize Attribute to the ItemController Class

    Update the ItemController and it's actions to use the logged in user information to allow individual users to have their own wishlists. ### Solution To view the solution, run git diff module1-solution <filepath>/<filename> in the Terminal, and press Enter to see the next lines of the difference. e.g. git diff module7-solution WishList/Controllers/ItemController.cs

    You may also update your local file browse the files of the solution by change diff to checkout e.g. git checkout module7-solution WishList/Controllers/ItemController.cs

About the author

Eric is a software developer who is passionate about always learning and improving. When he's not writing code, you'll find him playing computer games, guitar, disc golf, or learning something new.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight