Examine The Project Files
Examine The Project Files
Pages folder
Contains Razor pages and supporting files. Each Razor page is a pair of files:
A .cshtml file that has HTML markup with C# code using Razor syntax.
A .cshtml.cs file that has C# code that handles page events.
Supporting files have names that begin with an underscore. For example, the
_Layout.cshtml file configures UI elements common to all pages. _Layout.cshtml sets
up the navigation menu at the top of the page and the copyright notice at the
bottom of the page. For more information, see Layout in ASP.NET Core.
wwwroot folder
Contains static assets, like HTML files, JavaScript files, and CSS files. For more
information, see Static files in ASP.NET Core.
appsettings.json
Contains configuration data, like connection strings. For more information, see
Configuration in ASP.NET Core.
Program.cs
Contains the following code:
C#
Copy
var builder = WebApplication.CreateBuilder(args);
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
The following lines of code in this file create a WebApplicationBuilder with
preconfigured defaults, add Razor Pages support to the Dependency Injection (DI)
container, and builds the app:
C#
Copy
var builder = WebApplication.CreateBuilder(args);
The following code sets the exception endpoint to /Error and enables HTTP Strict
Transport Security Protocol (HSTS) when the app is not running in development mode:
C#
Copy
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for
production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
For example, the preceding code runs when the app is in production or test mode.
For more information, see Use multiple environments in ASP.NET Core.