using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.AspNetCore.ResponseCompression; using System.IO.Compression; var builder = WebApplication.CreateBuilder(args); builder.Services.AddResponseCompression(options => { options.EnableForHttps = true; options.Providers.Add(); options.Providers.Add(); }); builder.Services.Configure(options => { options.Level = CompressionLevel.Fastest; }); builder.Services.Configure(options => { options.Level = CompressionLevel.SmallestSize; }); // Add services to the container. builder.Services.AddControllersWithViews(); builder.Services.TryAddSingleton(); builder.Services.AddHostedService(); var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/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(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCors("AllowAnyOrigins"); app.UseRouting(); app.UseAuthorization(); app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Dashboard}/{id?}"); app.Run();