Exploring Razor Pages
Razor Pages allow a developer to easily mix HTML markup with C# code statements. That is why they use the .cshtml
file extension.
By default, ASP.NET Core looks for Razor Pages in a folder named Pages
.
Enabling Razor Pages
You will now change the static HTML page into a dynamic Razor Page, and then add and enable the Razor Pages service:
- In the
NorthwindWeb
project, create a folder namedPages
. - Copy the
index.html
file into thePages
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 statements to add Razor Pages and its related services like model binding, authorization, anti-forgery, views, and tag helpers, as shown highlighted in the following code:public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); }
- In
Startup.cs
, in the...