in UnicornStore/Startup.cs [113:196]
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//This is invoked when ASPNETCORE_ENVIRONMENT is 'Development' or is not defined
//The allowed values are Development,Staging and Production
if (env.IsDevelopment())
{
// StatusCode pages to gracefully handle status codes 400-599.
app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");
// Display custom error page in production when error occurs
// During development use the ErrorPage middleware to display error information in the browser
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
//This is invoked when ASPNETCORE_ENVIRONMENT is 'Production' or 'Staging'
if (env.IsProduction() || env.IsStaging())
{
// StatusCode pages to gracefully handle status codes 400-599.
app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");
app.UseExceptionHandler("/Home/Error");
}
app.UseHealthChecks("/health", new HealthCheckOptions()
{
Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
});
app.UseHealthChecks("/liveness", new HealthCheckOptions
{
Predicate = r => r.Name.Contains("self")
});
// force the en-US culture, so that the app behaves the same even on machines with different default culture
var supportedCultures = new[] { new CultureInfo("en-US") };
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-US"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
app.Use((context, next) =>
{
context.Response.Headers["Arch"] = RuntimeInformation.ProcessArchitecture.ToString();
return next();
});
// Configure Session.
app.UseSession();
// Add static files to the request pipeline
app.UseStaticFiles();
// Add the endpoint routing matcher middleware to the request pipeline
app.UseRouting();
// Add cookie-based authentication to the request pipeline
app.UseAuthentication();
// Add the authorization middleware to the request pipeline
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapAreaControllerRoute(
"admin",
"admin",
"Admin/{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute(
name: "api",
pattern: "{controller=Home}/{id?}");
});
}