How to increase request length to upload large files in .NET Core 6?
I have developed an ASP.NET Core Web API which is used to upload files. I am testing the API through postman. When I try to upload a file whose size is more than 28 MB it throws a request length exceeded error.
How to increase request length globally for IIS express and Dotnet CLI?
Add comment
Answers (1)
Add AnswerAfter a lot of research, I found this and it works for me.
//IIS
builder.Services.Configure<IISServerOptions>(options =>
{
options.MaxRequestBodySize = int.MaxValue;
});
//Kestrel
builder.Services.Configure<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize = int.MaxValue;
});
just add these pieces of code in your Program.cs