- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Core Tech
Guided: Building Your First Web Application with ASP.NET Core 10 MVC
This lab guides you through building an ASP.NET Core 10 MVC web application from a pre-configured starter project. Throughout the course of this lab, you will employ the fundamentals of the Model-View-Controller pattern along with updated features and paradigms from .NET 10 and C# 14. By the end of the lab, you'll have a functional web app and a solid understanding of how controllers, views, models, and data flow work together in ASP.NET Core.
Lab Info
Table of Contents
-
Challenge
Introduction
Welcome to the Guided: Building Your First Web Application with ASP.NET Core 10 MVC lab.
In this lab, you will need to build
PS-Taskboard, a simple project tracking board, using the ASP.NET Core 10 MVC pattern. The application displays a list of projects, each with a name, description, and status (Todo, In Progress, or Done).In the interest of time, all the files you need are already in the workspace. You won't need to be creating anything from scratch; instead you'll focus on the core "plumbing" of the MVC pattern: services, routing, controllers, dependency injection(DI), and view configuration.
There is a
solutiondirectory that you can check to compare your implementation with at any time. Note that the solution is one avenue of a "correct" answer; you're all set as long as your implementation is functionally the same and validates correctly. -
Challenge
Pipeline and Routing
Every ASP.NET Core application starts as an empty host. It doesn't know about controllers, views, or static files until you tell it.
In this step, you'll register the MVC services with the DI container, enable static-file serving via the .NET 10
MapStaticAssetsAPI, and map the default controller route so incoming HTTP requests are dispatched to the right controller action. -
Challenge
The Navigation Bridge
A controller's job is to act as a bridge between an incoming request and the response. When a user navigates to
/, the routing you set up in Step 1 dispatches the request toHomeController.Index(). Right now, that method throws aNotImplementedException— a clear signal that it's unfinished. You'll replace it with a call that tells the framework to find and render the matching view (Views/Home/Index.cshtml). -
Challenge
The Data Heartbeat
MVC separates concerns: controllers handle requests, views handle presentation, and models handle data. In this step, you'll implement a simple in-memory repository that provides project data, then register it as a service so any controller can request it through dependency injection.
-
Challenge
Dynamic Flow
This is the heart of the MVC pattern in action. The controller will:
- Receive the repository through constructor injection (the DI container provides it automatically).
- Retrieve the raw data from the repository.
- Map each
Projectinto aProjectListItemViewModel— translating the domain model into a shape designed for display. - Return the view with the ViewModel attached.
Take a look at
ViewModels/ProjectListViewModel.csto see the two classes you'll be working with:ProjectListViewModel(which holds a list of items) andProjectListItemViewModel(which hasId,Name,Description, andStatusLabelproperties). -
Challenge
UI Refinement
Up to this point the data flows in the order of repository → controller → view. But the views are rendering without the shared layout (no navigation bar, no consistent styling), the "View Projects" link on the home page is broken (
href="#"), and the project list page doesn't display individual project cards. In this step, you'll fix all three. After redefining the UI, thePsTaskboardshould be fully implemented and the lab is now complete.You can see the finished result that you've implemented by running
dotnet run --project PsTaskboardwithin the Terminal. Once the application is running, look in the Web Browser tab to see the webpage. There is also an option to open the Web Browser in another page to get a full webpage view ofPsTaskboard.
About the author
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.