Skip to content

Commit 948a737

Browse files
committed
Allow large file uploads by increasing request limits
Configured Kestrel and FormOptions to support very large uploads by setting MaxRequestBodySize and related limits to their maximum values. This removes restrictions on file upload size for incoming requests and form data.
1 parent d3d7465 commit 948a737

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

UDToolAPI/Program.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ public static void Main(string[] args)
88
{
99
var builder = WebApplication.CreateBuilder(args);
1010

11+
// Configure Kestrel to allow large uploads
12+
builder.WebHost.ConfigureKestrel(options =>
13+
{
14+
options.Limits.MaxRequestBodySize = long.MaxValue;
15+
});
16+
1117
// Add services to the container.
1218
builder.Services.AddControllers();
1319

1420
// Configure to allow large file uploads (no limit)
1521
builder.Services.Configure<FormOptions>(options =>
1622
{
1723
options.MultipartBodyLengthLimit = long.MaxValue;
24+
options.ValueLengthLimit = int.MaxValue;
25+
options.MemoryBufferThreshold = int.MaxValue;
1826
});
1927

2028
// Add Swashbuckle services

0 commit comments

Comments
 (0)