-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
C# 7.1 and .NET Core 2.0 - Modern Cross-Platform Development - Third Edition
By :
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.
ASP.NET Core runtime looks for Razor Pages in the Pages folder by default.
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...