Problem uploading large files with Kestrel + Docker
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Description
I have two issues with file uploads in ASP.Net Core running on Kestrel and Docker for Windows/Docker Desktop (Linux container):
1. When I try to upload a file that is larger than the default limit (30MB), my website hangs and I cannot make any further requests. I need to restart Docker Desktop and redeploy my website to get it running again.
2. I want to display a custom error page when a user attempts to upload a file that exceeds the default limit. I have implemented a middleware component to catch the BadHttpRequestException that is thrown and redirect to a custom error page. I have found that this doesn't work unless I either debug the code in Visual Studio and step-through the code or I insert a call to System.Threading.Thread.Sleep().
### To Reproduce
Steps to reproduce the behavior:
1. I am using Visual Studio 2017 15.9.4, ASP.NET Core SDK 2.2.101 and Docker Desktop 2.0.0.2 (30215)
2. I attach a file containing a sample project to reproduce the problem (see FileUpload.zip below). Run this code and navigate to the /Update controller. Upload a file larger than 30MB (mine was 64MB). In my environment, the website hangs.
3. Edit Startup.cs to uncomment the call to app.UseBadHttpRequestExceptionHandlerMiddleware().
Restart Docker Desktop and run the website again. Upload the file larger than 30MB again. This time, the custom error page should be displayed after a delay.
[FileUpload.zip](https://github.com/aspnet/AspNetCore/files/2760721/FileUpload.zip)
### Expected behavior
I was expecting the middleware to redirect to the custom error page without having to call Thread.Sleep() before Response.Redirect().
### Additional context
Here is the output of `dotnet --info`:
.NET Core SDK (reflecting any global.json):
Version: 2.2.101
Commit: 236713b0b7
Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.101\
Host (useful for support):
Version: 2.2.0
Commit: 1249f08fed
.NET Core SDKs installed:
1.0.0 [C:\Program Files\dotnet\sdk]
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.103 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.502 [C:\Program Files\dotnet\sdk]
2.2.101 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Contributor guide
Assessment
This issue has not been assessed yet.