chapter two

2 Your first application

 

This chapter covers

  • Creating a Razor Pages application
  • Adding your first page
  • Exploring the project files and the roles they play
  • Configuring the application pipeline with middleware

In the last chapter, you learned that the Razor Pages framework is a web development framework and how, as part of ASP.NET Core, it fits within the overall .NET framework. You have discovered the types of applications that you can build with Razor Pages, and also importantly when it is not the best solution to use. You have been introduced to the tools that you need to be productive with Razor Pages, and hopefully downloaded and installed Visual Studio or VS Code. along with the latest version of the .NET SDK. Now that you have your development environment set up, it’s time to start working with code.

In this chapter, you will create your first Razor Pages application. I will show you how to do that using both Visual Studio and the CLI, so that you can follow along on the operating system of your choice. Most web development frameworks provide a starter kit or project - a simple application that forms the starting point for your own application. Razor Pages is no different. The application that forms the starter kit only has three pages, but it includes a basic configuration that you can build on to create your own more complex application.

2.1 Creating your first website

2.1.1 Create a website using Visual Studio

2.1.2 Create a website using the Command Line Interface

2.1.3 Running the application

2.1.4 Adding a new page

2.1.5 Modify to include dynamic content

2.1.6 Add the page to the navigation

2.2 Explore the project files

2.2.1 The WebApplication1.sln file

2.2.2 The WebApplication1.csproj file

2.2.3 The bin and obj folders

2.2.4 The Properties folder

2.2.5 The wwwroot folder

2.2.6 The Pages Folder

2.2.7 The AppSettings files

2.2.8 Program.cs

2.3 Understanding middleware.

2.3.1 An HTTP refresher

2.3.2 The HttpContext

2.3.3 The Application Request Pipeline

2.3.4 Creating Middleware

2.3.5 Middleware Classes

2.4 Summary