ASP.NET Core: settings which will affect file upload
Host on IIS with InProcess mode:
web.config
<system.web>
<httpRuntime maxRequestLength="52428800" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<!-- change the max to 50 MB -->
<requestLimits maxAllowedContentLength="52428800" />
</requestFiltering>
</security>
</system.webServer>
Startup.ConfigureServices
services.Configure<IISServerOptions>(options =>
{
// 50 MB
options.MaxRequestBodySize = 52428800;
});
services.Configure<FormOptions>(options =>
{
// 50 MB
options.MultipartBodyLengthLimit = 52428800;
});
Host by Kestrel
Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel((context, options) =>
{
// Handle requests up to 50 MB
options.Limits.MaxRequestBodySize = 52428800;
})
.UseStartup<Startup>();
});
Host on nginx
.conf
client_max_body_size 50m;
创建时间:6/25/2022 11:48:37 PM
修改时间:6/26/2022 12:00:15 AM