...

/

Exploring ASP.NET Core Razor Pages

Exploring ASP.NET Core Razor Pages

Learn about ASP.NET Core Razor Pages setup, transforming static HTML dynamically with C#, configuring web apps, and handling HTTP requests.

ASP.NET Core Razor Pages allow developers to easily mix C# code statements with HTML markup to make the generated web page dynamic. That is why Razor Pages uses the .cshtml file extension. By convention, ASP.NET Core looks for Razor Pages in a folder named Pages.

Enabling Razor Pages

We will now copy and change the static HTML page into a dynamic Razor Page and then add and enable the Razor Pages service:

Step 1: In the Northwind.Web project folder, create a folder named Pages.

Step 2: Copy the index.html file into the Pages folder (in Visual Studio, hold down Ctrl while dragging and dropping.)

Step 3: For the file in the Pages folder, rename the file extension from .html to .cshtml.

Step 4: In index.cshtml, remove the <h2> element that says this is ...