Chapter 2. Your first application

 

This chapter covers

  • Creating your first ASP.NET Core web application
  • Running your application
  • Understanding the components of your application

After reading chapter 1, you should have a general idea of how ASP.NET Core applications work and when you should use them. You should have also set up a development environment to start building applications. In this chapter, you’ll dive right in by creating your first web app. You’ll get to kick the tires and poke around a little to get a feel for how it works, and in later chapters, I’ll show how you go about customizing and building your own applications.

As you work through this chapter, you should begin to get a grasp of the various components that make up an ASP.NET Core application, as well as an understanding of the general application-building process. Most applications you create will start from a similar template, so it’s a good idea to get familiar with the setup as soon as possible.

Definition

A template provides the basic code required to build an application. You can use a template as the starting point for building your own apps.

I’ll start by showing how to create a basic ASP.NET Core application using one of the Visual Studio templates. If you’re using other tooling, such as the .NET CLI, then you’ll have similar templates available. I use Visual Studio 2017 and ASP.NET Core 2.0 in this chapter, but I also provide tips for working with the .NET CLI.

2.1. A brief overview of an ASP.NET Core application

2.2. Creating your first ASP.NET Core application

2.3. Running the web application

2.4. Understanding the project layout

2.5. The csproj project file: defining your dependencies

2.6. The Program class: building a web host

2.7. The Startup class: configuring your application

2.8. MVC middleware and the home controller

2.9. Generating HTML with Razor template views

Summary

sitemap