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 they 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. - For the file in the
Pages
folder, rename the file extension from.html
to.cshtml
. - Remove the
<h2>
element that says that this is a static HTML page. - In
Startup.cs
, in theConfigureServices
method, add a statement to add ASP.NET Core Razor Pages and its related services, such as model binding, authorization, anti-forgery, views, and tag helpers, to the builder, as shown in the following...