MVC basics

    As the name suggests, MVC has three components: models, views, and controllers. Controllers handle incoming requests from a client or web browser and make decisions about what code to run. Views are templates (usually HTML plus some templating language like Handlebars, Pug, or Razor) that get data added to them and then are displayed to the user. Models hold the data that is added to views, or data that is entered by the user.

    • The controller creates a model with the information and attaches it to a view
    • The user clicks a button or submits a form, which sends a new request to the controller

    If you’ve worked with MVC in other languages, you’ll feel right at home in ASP.NET Core MVC. If you’re new to MVC, this chapter will teach you the basics and will help get you started.

    In this book, you’ll build a to-do app that lets the user add items to their to-do list and check them off once complete. You’ll build the server (the “backend”) using ASP.NET Core, C#, and the MVC pattern. You’ll use HTML, CSS, and JavaScript in the views (also called the “frontend”).