Reputation: 93
I'm stuck to the maximum limit of file upload in my .net core project. After adding the following code to program.cs, which is the limit of 25 mb as defult, I was able to do 120mb, but I can't exceed 120mb no matter what I do.
.UseKestrel (options =>
{
options.Limits.MaxRequestBodySize = 2147483648; // 2GB
});
I also added the following code to web.config.
<Configuration>
<System.webServer>
<Security>
<RequestFiltering>
<requestLimits maxAllowedContentLength = "2147483648" />
</ RequestFiltering>
</ Security>
</System.webServer>
<System.web>
<httpRuntime maxRequestLength = "2147483648" executionTimeout = "1000000" />
</System.web>
</ Configuration>
Upvotes: 2
Views: 1460
Reputation: 4733
If you're using Multipart forms to upload the file, then you should change the limit here:
services.Configure<FormOptions>(x =>
{
x.ValueLengthLimit = 2147483648;
x.MultipartBodyLengthLimit = 2147483648;
x.MultipartHeadersLengthLimit = 2147483648;
});
Upvotes: 2
Reputation: 3646
Have you tried adding the attribute to your action directly?
[RequestSizeLimit(1024000)]
public async Task<IActionResult> UploadFile(IFormFile file)
{
// your code here
}
Upvotes: 1