Advertisement
Intermediate ASP.NET Core, File Uploads & Streaming Large Files

How do you configure IIS or a reverse proxy like nginx to allow large file uploads, given they may impose their own separate size limits beyond Kestrel's?

Short answer

When ASP.NET Core is hosted behind IIS or a reverse proxy, the proxy layer itself may enforce its own separate maximum request body size (IIS's maxAllowedContentLength in web.config, nginx's client_max_body_size directive) independent of Kestrel's own limit -- all layers in the…

Save ASP.NET Core mock interview
Advertisement
AModel answer
When ASP.NET Core is hosted behind IIS or a reverse proxy, the proxy layer itself may enforce its own separate maximum request body size (IIS's maxAllowedContentLength in web.config, nginx's client_max_body_size directive) independent of Kestrel's own limit -- all layers in the request path (proxy, Kestrel, and any explicit [RequestSizeLimit] attributes) must be configured consistently, since the most restrictive limit in the chain determines the effective maximum.
<!-- web.config for IIS -->
<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="104857600" />  <!-- 100MB -->
  </requestFiltering>
</security>

# nginx.conf
client_max_body_size 100M;
Real-world example
A team spends hours debugging why uploads larger than 30MB fail despite setting a generous 500MB Kestrel limit, eventually discovering nginx's default client_max_body_size of 1MB in front of their app was the actual restrictive bottleneck.
Likely follow-ups
  • What's the full chain of size limits a large upload must pass through in a typical production deployment?
  • How would you diagnose which specific layer is rejecting an oversized upload?
Related topics