Razor Pages allow a developer to easily mix HTML markup with C# code statements. That is why they use the .cshtml
file extension. The Razor syntax is indicated by the @
symbol.
In the NorthwindWeb
project, create a folder named Pages
.
Move the index.html
file into the Pages
folder, and rename the file extension from .html
to .cshtml
.
To enable Razor Pages, we must add and enable a service named MVC, because Razor Pages is a part of MVC.
In Startup.cs
, in the ConfigureServices
method, add statements to add MVC, as shown in the following code:
public void ConfigureServices(IServiceCollection services) { services.AddMvc(); }
In Startup.cs
, in the Configure
method, after the existing statements to use default files and static files, add a statement to use MVC, as shown in the following code:
app.UseDefaultFiles(); // index.html, default.html, and so on
app.UseStaticFiles();
app...