Description
This article explains how to configure max upload file size for CMS 12 web apps. The suggestion below works with Kestrel and DXP Linux platform.
This resolves issues when uploading files larger than 30MB.
Steps
1. Configure FormOptions and CMS UploadOptions in Startup.cs ConfigureServices method
services.Configure<FormOptions>(x => { x.MultipartBodyLengthLimit = 52428800; });
services.Configure<UploadOptions>(x =>
{
x.FileSizeLimit = 52428800;
});
2. Configure maximum request size:
Option 1: Setting max request size for specific requests and paths in Startup.cs Configure method
// Example for /episerver path
// Before app.UseEndpoints()
app.Use(async (context, next) => {
if (context.Request.Path.StartsWithSegments("/episerver"))
{
context.Features.Get<IHttpMaxRequestBodySizeFeature>().MaxRequestBodySize = int.MaxValue;
}
await next();
});
Option 2: Configure globally for all requests in Program.cs
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseKestrel(options => { options.Limits.MaxRequestBodySize = 52428800; //50MB }); }
Please sign in to leave a comment.