Free course · From scratch to advanced
ASP.NET Core MVC
Learn ASP.NET Core MVC from scratch: the request life cycle, controllers and views, models and forms, state management, security and testing, with a diagram for every topic.
Module 1
Start from scratch
What .NET and ASP.NET Core are, how to create and run your first MVC app, and what every file in a new project does.
Lesson 1: What are .NET and ASP.NET Core?Beginner
Before writing any code it helps to know what you are building on. This lesson explains what .NET is, what ASP.NET Core adds on top of it, and which ASP.NET Core style (MVC, Razor Pages, Blazor or APIs) fits which job.
Lesson 2: Create your first MVC app in Visual Studio 2026Beginner
The easiest way to start is Visual Studio 2026 on Windows. This lesson walks through installing it, creating an ASP.NET Core MVC project click by click, running it, and adding your own controller and view, so you finish with a working app. There is also a command-line route for macOS and Linux.
Lesson 3: Project structure and Program.csBeginner
A new MVC project contains a handful of folders and files, and each has a clear job. This lesson tours the project, then reads Program.cs line by line so you understand how the app is configured and in which order things run.
Lesson 4: What is ASP.NET Core MVC?Beginner
ASP.NET Core MVC is a framework for building web apps and APIs using the Model-View-Controller pattern. This lesson explains what each of the three parts does, how a request flows through them, and how to switch MVC on in a new app.
Lesson 5: How an ASP.NET Core app works: the big pictureBeginner
One picture of everything that happens when someone opens a page in an ASP.NET Core MVC app: startup, Kestrel, the middleware pipeline, the controller, services, EF Core, SQL Server, the Razor view and the response. Keep it open while you work through the rest of the course.
Module 2
Request life cycle
How a request travels from the browser through the server, middleware, routing, filters, the controller and the view, and back as a response.
Lesson 6: The request life cycle, from start to endBeginner
If you come from ASP.NET Web Forms you may know the page life cycle. ASP.NET Core MVC has no page events; instead every request follows a request life cycle. This lesson traces one request from the moment the browser sends it to the moment HTML comes back.
Lesson 7: The middleware pipelineIntermediate
Middleware is the chain of components every request passes through. This lesson shows how the chain is built, why the order matters so much, and how to write your own middleware class.
Lesson 8: Routing to controller actionsBeginner
Routing decides which controller action runs for a given URL. ASP.NET Core MVC supports conventional routes defined once in Program.cs and attribute routes placed on controllers and actions. This lesson explains both, route parameters and constraints, and how to generate links that stay correct.
Lesson 9: Filters and the filter pipelineIntermediate
Filters let you run code before and after specific stages of an MVC action, such as authorization, model binding, the action itself and the result. This lesson shows the filter pipeline, the filter types and how to write and register your own.
Module 3
Controllers and views
Handle requests in controllers and build pages with Razor views, layouts, partial views, view components and Tag Helpers.
Lesson 10: Controllers and actionsBeginner
Controllers group the code that handles requests, and each public method on a controller is an action. This lesson shows how MVC finds controllers, what action methods can return, and the helper methods that make returning views, redirects and errors short and clear.
Lesson 11: Action results: views, JSON, redirects and filesBeginner
An action decides what goes back to the browser by returning an action result. This lesson walks through the results you will use most: views, partial views, redirects, JSON, files and status codes such as 404, and when to pick each one.
Lesson 12: Passing data to views: models, ViewData and ViewBagBeginner
Controllers hand data to views in a few ways: a strongly typed model, ViewData, ViewBag and TempData. This lesson shows each one, why the model should carry almost everything, and where the other three still fit.
Lesson 13: View models and mappingIntermediate
A view model is a class shaped for one screen, separate from your database entities. This lesson shows why passing entities straight to views causes bugs and security holes, how to build view models for display and edit forms, and how to map between them.
Lesson 14: Async actions with async and awaitIntermediate
Most actions wait on a database, a file or another web service. Writing them with async and await lets the server handle far more requests with the same hardware. This lesson shows how to write async actions correctly and the mistakes that cancel out the benefit.
Lesson 15: Views in ASP.NET Core MVCBeginner
Views are Razor files that turn data from a controller into HTML. This lesson covers where views live, how MVC finds the right one, the difference between strongly typed models and ViewData or ViewBag, and how to keep views simple.
Lesson 16: Razor syntax basicsBeginner
Razor is the markup syntax used in MVC views. It switches between HTML and C# with the @ symbol. This lesson covers expressions, code blocks, conditions, loops, comments, and how Razor keeps output safe by encoding it.
Lesson 17: Layouts, _ViewStart and _ViewImportsBeginner
Most pages on a site share the same header, navigation and footer. Layouts let you write that frame once. This lesson explains _Layout.cshtml, RenderBody, sections, _ViewStart.cshtml and _ViewImports.cshtml.
Lesson 18: Partial viewsIntermediate
A partial view is a reusable piece of Razor markup, such as a product card or an address block, that you render inside other views. This lesson shows how to create one, pass it a model and render it the right way.
Lesson 19: View componentsIntermediate
A view component is like a small controller and view bundled together, used to render a reusable piece of a page that needs its own data, such as a login panel, a menu or a cart summary. This lesson shows how to build and invoke one.
Lesson 20: Tag HelpersBeginner
Tag Helpers let server-side code take part in creating HTML elements, using attributes that look like normal HTML. This lesson covers how to enable them, the built-in ones you use daily, such as links, forms and images, and how to write a simple custom one.
Lesson 21: Organizing apps with areasIntermediate
As an app grows, the Controllers and Views folders get crowded. Areas let you split a large MVC app into sections, such as Admin and Store, each with its own controllers and views. This lesson shows the folder layout, routing and links.
Module 4
Models and forms
Get data from forms and URLs into your models, validate it, and show it back to users.
Lesson 22: Model bindingBeginner
Model binding takes values from the HTTP request, such as form fields, route values and the query string, and turns them into the typed parameters and objects your action expects. This lesson shows where values come from, how to control the source, and how to avoid over-posting.
Lesson 23: Model validationBeginner
Validation makes sure data is correct before you use it. ASP.NET Core MVC checks rules you declare with attributes, records the results in ModelState, and can also validate in the browser. This lesson covers the common attributes, checking ModelState and showing errors.
Lesson 24: Client-side validationBeginner
Client-side validation shows form errors instantly in the browser, before anything is sent. This lesson shows how ASP.NET Core turns your data annotations into browser checks, how to switch it on, and why the server must always validate again.
Lesson 25: Building forms with Tag HelpersBeginner
Forms are how users send data to your app. This lesson builds a complete form with Tag Helpers: the form, labels, inputs, a drop-down and validation messages, plus the GET and POST actions that show and process it.
Lesson 26: Sorting, filtering and paging a listIntermediate
Almost every app has a list page with search, sort and paging. This lesson builds one end to end: query string parameters, an IQueryable that stays in the database, a page model, and links that keep the current filters.
Lesson 27: Calling actions from JavaScript with fetchIntermediate
Sometimes a page should update without a full reload, such as adding to a cart or loading more comments. This lesson calls MVC actions from JavaScript with fetch, sends the anti-forgery token, and chooses between returning JSON and returning a partial view.
Lesson 28: Display and editor templatesIntermediate
Display and editor templates let you define once how a type, such as an Address or a money value, should be shown or edited, and reuse that everywhere. This lesson shows DisplayFor, EditorFor, template folders and formatting attributes.
Lesson 29: Uploading filesAdvanced
Letting users upload files is useful and risky. This lesson shows how to receive files with IFormFile, how to save them safely, and the security checks you should never skip.
Lesson 30: Custom model bindingAdvanced
Built-in model binding handles simple types and objects made of them. When a value arrives in a custom format, such as "12.97,77.59" for a map point, you can teach MVC to bind it. This lesson shows a custom IModelBinder and when simpler options are enough.
Module 5
State management
HTTP forgets everything between requests. Learn every way to remember data: query strings, hidden fields, TempData, cookies, session and caching.
Lesson 31: State management: all the optionsBeginner
HTTP is stateless: the server forgets everything about a request once it has answered. State management is how your app remembers things between requests, such as a search filter, a message after a redirect, a logged-in user or a shopping cart. This lesson compares every option so you can pick the right one.
Lesson 32: TempDataBeginner
TempData holds a value until it is read, which makes it ideal for showing a message after a redirect, such as "Your order was saved". This lesson shows how TempData works, how long values live, and the Keep and Peek methods.
Lesson 33: CookiesIntermediate
A cookie is a small piece of data the server asks the browser to store and send back with every later request. This lesson shows how to write, read and delete cookies in ASP.NET Core and which options keep them safe.
Lesson 34: Session stateIntermediate
Session state keeps per-user data on the server for the length of a visit, such as a shopping cart for a visitor who is not signed in. This lesson shows how to turn session on, read and write values, and what to watch out for when the app runs on several servers.
Lesson 35: In-memory cachingIntermediate
Caching keeps the result of slow work, such as a database query or an API call, in memory so later requests can reuse it. This lesson shows IMemoryCache, expiration options and the cache-aside pattern.
Lesson 36: Response cachingAdvanced
Response caching lets browsers, proxies or the server reuse a whole HTTP response instead of running your action again. This lesson explains Cache-Control headers, the [ResponseCache] attribute and server-side output caching.
Lesson 37: Output cachingAdvanced
Output caching stores a whole response and serves it again without running the action. This lesson shows the output caching middleware added in .NET 7, policies with expiry and vary-by rules, tag-based invalidation, and what must never be cached.
Module 6
Configuration, DI and logging
The building blocks every real app uses: dependency injection, configuration, environments, logging, error handling and static files.
Lesson 38: Dependency injection and service lifetimesIntermediate
Dependency injection (DI) is how ASP.NET Core gives your classes the services they need, instead of each class creating its own. This lesson explains the idea, how to register services, and the three lifetimes: transient, scoped and singleton.
Lesson 39: Injecting services into controllers and viewsIntermediate
Once services are registered, controllers and views can use them. This lesson shows constructor injection in controllers, injecting into a single action with [FromServices], using @inject in Razor views, and reading settings with the options pattern.
Lesson 40: Configuration and appsettings.jsonIntermediate
Settings such as connection strings, API endpoints and page sizes should not be hard-coded. ASP.NET Core reads configuration from several sources and merges them, so the same app can use different settings on your laptop and in production. This lesson explains the sources, their order, and how to keep secrets out of source control.
Lesson 41: The options patternIntermediate
The options pattern turns sections of appsettings.json into strongly typed classes. This lesson binds settings to a class, validates them at startup so a typo fails fast, and explains IOptions, IOptionsSnapshot and IOptionsMonitor.
Lesson 42: Keeping secrets safe: user secrets and Key VaultIntermediate
Connection strings, API keys and passwords must never be committed to source control. This lesson shows where secrets belong at each stage: user secrets on your machine, environment variables or Azure Key Vault in production, and managed identities so many secrets disappear entirely.
Lesson 43: Development, Staging and Production environmentsIntermediate
Your app behaves differently on your laptop and on the live server: detailed errors locally, friendly error pages in production, different databases. ASP.NET Core handles this with named environments. This lesson explains how the environment is chosen and how to use it.
Lesson 44: LoggingIntermediate
Logs tell you what your app is doing in production, where you cannot attach a debugger. This lesson shows how to write logs with ILogger, how log levels and categories filter them, and why structured logging beats string concatenation.
Lesson 45: Calling other services with IHttpClientFactoryIntermediate
Most apps call other web APIs. This lesson shows why new HttpClient() in each request causes problems, how IHttpClientFactory and typed clients fix them, and how to add timeouts and retries with the standard resilience handler.
Lesson 46: Background tasks with hosted servicesAdvanced
Some work should not happen inside a web request: sending emails, cleaning old data or processing uploads. This lesson builds a BackgroundService, shows how to use scoped services such as a DbContext inside it, and adds a queue so actions can hand off work.
Lesson 47: Health checksIntermediate
Health checks give load balancers, containers and monitoring tools a simple URL that says whether your app works. This lesson sets up liveness and readiness endpoints, checks the database, and writes a custom check.
Lesson 48: Handling errorsIntermediate
Errors will happen. What matters is that users see a friendly page, you get the details in your logs, and nothing sensitive leaks. This lesson covers the developer exception page, the exception handler middleware, status code pages and the Error action.
Lesson 49: Serving static filesBeginner
CSS, JavaScript, images and fonts are static files: the server sends them as they are. This lesson explains the wwwroot folder, how static files are served and cached, and how to make sure browsers pick up new versions.
Lesson 50: Globalization and localizationAdvanced
If your users speak different languages or format dates and money differently, localization lets one app serve them all. This lesson covers cultures, resource files, IStringLocalizer and IViewLocalizer, and how the request culture is chosen.
Module 7
Web APIs and real time
Return JSON from API controllers, compare minimal APIs, call them from JavaScript, allow other sites with CORS, secure them with JWT and push live updates with SignalR.
Lesson 51: Web API controllersIntermediate
An API controller returns data, usually JSON, for JavaScript front ends, mobile apps or other services. This lesson builds a REST API for products with [ApiController], correct status codes, ProblemDetails errors and OpenAPI documentation.
Lesson 52: Minimal APIs compared with MVCIntermediate
Minimal APIs define endpoints with a few lines in Program.cs instead of controller classes. This lesson shows the same products API written the minimal way, how to organize endpoints as an app grows, and how to choose between minimal APIs and controllers.
Lesson 53: Cross-origin requests (CORS)Intermediate
Browsers block JavaScript on one site from reading responses from another site unless the server allows it. This lesson explains the same-origin policy, how CORS lets your API opt in for specific origins, preflight requests, and the configuration mistakes that open security holes.
Lesson 54: Securing APIs with JWT bearer tokensAdvanced
APIs used by mobile apps and single-page apps usually authenticate with bearer tokens instead of cookies. This lesson explains what a JWT contains, how to validate tokens from an identity provider in ASP.NET Core, and how to protect endpoints with policies and scopes.
Lesson 55: Real-time updates with SignalRAdvanced
SignalR pushes updates from the server to browsers in real time, for chat, notifications, live dashboards and order tracking. This lesson builds a hub, connects from JavaScript, sends to one user or a group, and covers scaling to several servers.
Module 8
Security
Protect your app with HTTPS, anti-forgery tokens, ASP.NET Core Identity and authorization by role and policy.
Lesson 56: Enforcing HTTPSIntermediate
Every page of a modern site should be served over HTTPS, so data between the browser and your server is encrypted. This lesson shows how ASP.NET Core redirects HTTP to HTTPS, what HSTS adds, and how the development certificate works.
Lesson 57: Preventing cross-site request forgeryIntermediate
Cross-site request forgery (CSRF) tricks a signed-in user's browser into submitting a form to your site from another site. Anti-forgery tokens stop it. This lesson explains the attack and shows how ASP.NET Core MVC protects forms and AJAX requests.
Lesson 58: Preventing XSS and adding security headersIntermediate
Cross-site scripting (XSS) lets an attacker run their JavaScript in your users' browsers. This lesson shows how Razor protects you by default, the few ways developers break that protection, and the security headers, including a Content Security Policy, that add a second layer.
Lesson 59: Cookie authentication without IdentityIntermediate
ASP.NET Core Identity is the full solution for user accounts, but sometimes you only need a simple sign-in, such as an admin area or users stored in an existing table. This lesson builds cookie authentication by hand with claims, sign-in, sign-out and protected actions.
Lesson 60: ASP.NET Core IdentityAdvanced
ASP.NET Core Identity is the built-in system for user accounts: registration, sign-in, password hashing, lockout, two-factor authentication and external logins. This lesson shows what Identity gives you, how it stores users with EF Core and how sign-in works.
Lesson 61: Sign in with Google and Microsoft accountsAdvanced
Letting users sign in with Google or Microsoft saves them a password and saves you from storing one. This lesson explains how OpenID Connect sign-in works, registers an app with a provider, configures ASP.NET Core, and links external accounts to your own users.
Lesson 62: Authorization with the [Authorize] attributeIntermediate
Once you know who the user is, authorization decides what they may do. This lesson covers the [Authorize] and [AllowAnonymous] attributes, what happens when access is denied, and how to require sign-in for the whole app by default.
Lesson 63: Role-based authorizationAdvanced
Roles group users by job, such as Admin, Manager or Customer, and let you allow whole groups into parts of the app. This lesson shows how to create roles with Identity, assign users to them and protect actions by role.
Lesson 64: Policy-based authorizationAdvanced
Policies describe access rules in one place, such as "must be an employee" or "must be over 18", and let you reuse them across the app. This lesson shows simple claim and role policies and a custom requirement with its handler.
Lesson 65: Rate limitingAdvanced
Rate limiting caps how many requests a client can make in a period. It protects logins from password guessing, APIs from abuse and your server from overload. This lesson uses the built-in rate limiting middleware with fixed window, sliding window, token bucket and concurrency limiters.
Module 9
Testing and deployment
Prove your app works with unit and integration tests, then publish it.
Lesson 66: Unit testing controllersAdvanced
Unit tests check a small piece of code in isolation, quickly and automatically. This lesson shows how to test an MVC controller action: replacing its services with fakes, calling the action and checking the result it returns.
Lesson 67: Integration testsAdvanced
Integration tests run your whole app in memory and send it real HTTP requests, so routing, middleware, filters, controllers and views are all tested together. This lesson shows WebApplicationFactory and how to swap in a test database.
Lesson 68: Performance best practicesAdvanced
Most slow ASP.NET Core apps are slow for the same few reasons: too many or too big database queries, blocking calls, no caching and large responses. This lesson is a practical checklist, with how to measure before you change anything.
Lesson 69: Publishing and deploying your appIntermediate
An app is only useful once it runs somewhere users can reach. This lesson explains dotnet publish, framework-dependent and self-contained output, the common hosting options, and a checklist for a safe first deployment.
Lesson 70: Deploying to Azure App ServiceIntermediate
Azure App Service runs ASP.NET Core apps without managing servers. This lesson walks through creating an App Service and an Azure SQL database, publishing the app, setting configuration and connection strings safely, and the settings to check after the first deploy.
Lesson 71: Running your app in DockerAdvanced
A container packages your app with everything it needs to run, so it behaves the same on your laptop, in CI and in production. This lesson writes a multi-stage Dockerfile for an ASP.NET Core app, runs it with SQL Server using Docker Compose, and covers .NET's built-in container publishing.
Lesson 72: CI/CD with GitHub ActionsAdvanced
Continuous integration builds and tests every change automatically, and continuous deployment ships the main branch without manual steps. This lesson writes a GitHub Actions workflow that builds, tests and deploys an ASP.NET Core app to Azure App Service using OpenID Connect instead of stored passwords.
Module 10
Build a complete app
Put every module together: build, secure, test and deploy a complete MVC app step by step.
Lesson 73: Build a complete task manager app from start to finishIntermediate
This final project ties the course together by building a small but complete task manager: sign-in, a database with EF Core, list pages with search and paging, validated forms, AJAX, tests and deployment. Each step lists the lessons to revisit, so you can build it on your own.