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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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

  1. 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.
  2. 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

  1. 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

  1. 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

  1. 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.
  2. 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

  1. 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.
  2. 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

  1. 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.