Ada*_*ith 9 asp.net asp.net-mvc asp.net-core
如何为ASP.NET CORE应用程序设置最大上传大小?
在过去,我能够将其设置为web.config文件,如下所示:
<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="52428800" />
        </requestFiltering>
    </security>
</system.webServer>
有两种方法可以做到这一点:
1.使用应用程序明智的设置 - 在 >配置服务方法中。
services.Configure<FormOptions>(options =>
{
    options.MultipartBodyLengthLimit = 52428800;
});
2.使用RequestFormSizeLimit属性-用于特定操作。- 尚未在官方包 Unofficial中提供
您可以在方法中配置分段上传的最大限制ConfigureServices:
public void ConfigureServices(IServiceCollection services)
{
    services.Configure<FormOptions>(options =>
    {
        options.MultipartBodyLengthLimit = 52428800;
    });
    services.AddMvc();
}
MaxRequestBufferSize您还可以使用 进行配置services.Configure<KestrelServerOptions>,但看起来这将在下一个版本中被弃用。