using System.Text.Json.Serialization; using ImageConvertService.Biz; using ImageConvertService.ExceptionHandling; using Microsoft.AspNetCore.Server.Kestrel.Core; var builder = WebApplication.CreateBuilder(args); // Add services to the container. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services .AddControllersWithViews(options => options.Filters.Add()) .AddJsonOptions(options => options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter())); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.Configure(options => { options.Limits.MaxRequestBodySize = 8000 * 1024 * 1024L; // 设置最大请求体大小 8GB }); var app = builder.Build(); // Configure the HTTP request pipeline. //if (app.Environment.IsDevelopment()) //{ app.UseSwagger(); app.UseSwaggerUI(); //} //app.UseHttpsRedirection(); //app.AddExample(); app.MapControllers().WithFormOptions(multipartBodyLengthLimit: 8000 * 1024 * 1024L); // 设置表单最大请求体大小 8GB app.Run();