ASP.NET Core MVC
ASP.NET Core is how .NET builds for the web. You will learn how the browser and server talk, then build your first MVC web app: controllers that answer requests, Razor views that turn a model into HTML, and forms that send data back.
Updated
Network Communication
- Network Communication in C#: an overview (Novice): Programs talk to each other by sending messages over a network, even when both run on the same computer. Your C# app already does this with SQL Server; a browser does it with a web app.
- IP Addresses and Ports (Novice): An IP address finds the computer, and a port finds the program on it. Meet localhost, the ports the web uses, and the ports your own apps listen on.
- How to read a URL (Novice): A URL has five parts (protocol, domain name, port, path and query string), and each one tells the web server something about the request.
- Static Websites (Apprentice): A static website is built from hand-written HTML files, so the path in a page's URL is the path to that file on the server.
- Request / Response (Apprentice): The browser sends a request and the server sends back one response, and the server does not remember earlier requests.
ASP.NET Core
- What is ASP.NET Core (Novice): ASP.NET Core is .NET's framework for the web. It listens for requests, runs your C# to answer each one, and sends back a page built for that request.
- Creating an MVC Project (Apprentice): Create an ASP.NET Core MVC project, run it in the browser, and find your way around its folders and Program.cs.
The MVC Pattern
- The MVC Pattern in ASP.NET Core (Apprentice): MVC splits a web app into models that carry data, views that turn it into HTML, and controllers that answer requests. Follow one request through all three.
Controllers and Actions
- Controllers and Actions (Journeyman): A controller is a class whose public methods, its actions, answer requests. Learn how the default route picks one from the address, where parameters come from, and what an action can return.
Razor Views
- Passing a Model to a View (Journeyman): An action hands its view a model with View(model); the view names the model's type with @model and reads it through Model. ViewData carries small extras, such as the page title.
- Razor Syntax and Tag Helpers (Journeyman): Mix C# into HTML with Razor's @ expressions, code blocks, if and foreach, and let tag helpers such as asp-action and asp-route-id write your links.
MVC Forms
- GET and POST Actions (Journeyman): A search form sends a GET request with a query string; a form that saves data sends a POST. Pair a GET action that shows the form with a POST action that saves it, redirect afterward, and protect it with an anti-forgery token.
- Model Binding a Form (Journeyman): ASP.NET Core fills an action's parameters, even a whole Product, from the request by matching names. asp-for writes inputs whose names match the model, and ModelState says when a value didn't fit.
Exercise: BooksPlus
- Exercise: BooksPlus (Journeyman): Turn a new ASP.NET Core MVC project into a small bookstore website for BooksPlus, with featured books, a list, details, search and a form that adds a book, and run tests that request every page.