diff --git a/DotNet/ASP.NET/App Configuration.md b/DotNet/ASP.NET/App Configuration.md index d2949a9..6102d3f 100644 --- a/DotNet/ASP.NET/App Configuration.md +++ b/DotNet/ASP.NET/App Configuration.md @@ -1,5 +1,17 @@ # ASP.NET Configuration +## `.csproj` + +```xml + + + true + + + $(NoWarn);1591 + +``` + ## `Program.cs` ```cs @@ -78,12 +90,20 @@ namespace App services.AddServerSideBlazor(); // needs Razor Pages services.AddSignalR(); - + // set dependency injection lifetimes services.AddSingleton(); services.AddScoped(); services.AddTransient(); - + + // add swagger + services.AddSwaggerGen(options => { + + // OPTIONAL: use xml comments for swagger documentation + var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; + options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename)); + }); + } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -99,6 +119,7 @@ namespace App // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } + app.UseHttpsRedirection(); app.UseStaticFiles(); @@ -106,6 +127,9 @@ namespace App app.UseAuthorization(); + app.UseSwagger(); + app.UseSwaggerUI(); + app.UseEndpoints(endpoints => { // MVC routing