dotnet / dotnet/AspNetCore.Docs

UUF: File Uploads: Missing IISServerOptions and IHttpMaxRequestBodySizeFeature

Closed
#36,039 0 comments 1 reaction 2 assignees Claimed by @tdykstra View on GitHub
aspnet-core/svc mvc/subsvc Source - Docs.ms user-feedback
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

### Description

**User feedack transferred from UUF system:**
"IISServerOptions is not documented in the IIS section while it also has options impacting file upload size restrictions. Same for IHttpMaxRequestBodySizeFeature"

[AI assisted problem/solution detail follows]
**Feedback on File Uploads documentation: Missing IISServerOptions and IHttpMaxRequestBodySizeFeature information**

**The problem:**
- IISServerOptions.MaxRequestBodySize is briefly mentioned, but lacks context about how it interacts with other IIS limits
- IHttpMaxRequestBodySizeFeature is not mentoned at all but should be

**Suggested improvements:**
1. Expand the IIS section to provide more details about IISServerOptions.MaxRequestBodySize and clarify how it interacts with the IIS maxAllowedContentLength setting
2. Add documentation about IHttpMaxRequestBodySizeFeature, explaining how it can be used to modify request body size limits for specific requests
3. Include a code example showing how to use IHttpMaxRequestBodySizeFeature in practice

**Proposed code example to add:**

```csharp
// Example showing how to use IHttpMaxRequestBodySizeFeature for a specific request
app.Use(async (context, next) =>
{
// For a specific endpoint that needs a larger size limit
if (context.Request.Path.StartsWithSegments("/api/largefiles"))
{
// Get the feature from the request
var requestSizeFeature = context.Features.Get();

if (requestSizeFeature != null && requestSizeFeature.IsReadOnly == false)
{
// Allow requests up to 100 MB for this specific endpoint
requestSizeFeature.MaxRequestBodySize = 104857600; // 100 MB
}
}

await next.Invoke();
});
```
----

### Page URL

https://learn.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-9.0

### Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/mvc/models/file-uploads.md

### Document ID

c6787f0f-3e9a-6efb-0e6e-5ccb957d3f4a

### Platform Id

a281e7a8-71e2-c3ec-e6dc-c5c6161ae486

### Article author

@tdykstra

### Metadata

* ID: 9a5cfa38-0e6c-4346-dafc-84ea5c513fcf
* PlatformId: a281e7a8-71e2-c3ec-e6dc-c5c6161ae486
* Service: **aspnet-core**
* Sub-service: **mvc**

[Related Issues](https://github.com/dotnet/AspNetCore.Docs/issues?q=is%3Aissue+is%3Aopen+c6787f0f-3e9a-6efb-0e6e-5ccb957d3f4a)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.