Last active
August 19, 2021 02:11
-
-
Save germ13/901d27eecd6d9640033146ce7001760c to your computer and use it in GitHub Desktop.
Boilerplate Startup.cs for dotnet web project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
{ | |
if (env.IsDevelopment()) | |
{ | |
app.UseDeveloperExceptionPage(); | |
app.UseDatabaseErrorPage(); | |
} | |
else | |
{ | |
app.UseExceptionHandler("/Error"); | |
app.UseHsts(); | |
} | |
/* | |
if (env.IsProduction() || env.IsStaging() || env.IsEnvironment("Staging_2")) | |
{ | |
app.UseExceptionHandler("/Error"); | |
} | |
*/ | |
app.UseHttpsRedirection(); | |
app.UseStaticFiles(); | |
// app.UseCookiePolicy(); | |
app.UseRouting(); | |
// app.UseRequestLocalization(); | |
// app.UseCors(); | |
app.UseAuthentication(); | |
app.UseAuthorization(); | |
// app.UseSession(); | |
// app.UseResponseCompression(); | |
// app.UseResponseCaching(); | |
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapRazorPages(); | |
endpoints.MapControllerRoute( | |
name: "default", | |
pattern: "{controller=Home}/{action=Index}/{id?}"); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment