3 Your first ASP.NET Core application

 

This chapter covers

  • Using ASP.NET Core to create an application that accepts RSVP responses
  • Creating a simple data model
  • Creating a controller and view that presents and processes a form
  • Validating user data and displaying validation errors
  • Applying CSS styles to the HTML generated by the application

Now that you are set up for ASP.NET Core development, it is time to create a simple application. In this chapter, you’ll create a data-entry application using ASP.NET Core. My goal is to demonstrate ASP.NET Core in action, so I will pick up the pace a little and skip over some of the explanations as to how things work behind the scenes. But don’t worry; I’ll revisit these topics in-depth in later chapters.

3.1 Setting the scene

Imagine that a friend has decided to host a New Year’s Eve party and that she has asked me to create a web app that allows her invitees to electronically RSVP. She has asked for these four key features:

  • A home page that shows information about the party
  • A form that can be used to RSVP
  • Validation for the RSVP form, which will display a thank-you page
  • A summary page that shows who is coming to the party

In this chapter, I create an ASP.NET Core project and use it to create a simple application that contains these features; once everything works, I’ll apply some styling to improve the appearance of the finished application.

3.2 Creating the project

3.2.1 Preparing the project

3.2.2 Adding a data model

3.2.3 Creating a second action and view

3.2.4 Linking action methods

3.2.5 Building the form

3.2.6 Receiving form data

3.2.7 Adding the Thanks view

3.2.8 Displaying responses

3.2.9 Adding validation

3.2.10 Styling the content

Summary