Exploring ASP.NET Core Razor Pages
ASP.NET Core Razor Pages allow a developer to easily mix C# code statements with HTML markup to make the generated web page dynamic. That is why Razor Pages use the .cshtml
file extension.
By convention, ASP.NET Core looks for Razor Pages in a folder named Pages
.
Enabling Razor Pages
You will now copy and change the static HTML page into a dynamic Razor Page, and then add and enable the Razor Pages service:
- In the
Northwind.Web
project folder, create a folder namedPages
. - Copy the
index.html
file into thePages
folder. (In Visual Studio 2022 or JetBrains Rider, hold down Ctrl while dragging and dropping.) - For the file in the
Pages
folder, rename the file extension forindex.html
from.html
to.cshtml
. - In the
Pages
folder, inindex.cshtml
, add the@page
directive to the top of the file. - In
index.cshtml
, remove the<h2>
element that says that this is a static HTML page. - In
Program.cs
, after...