dotnet / dotnet/AspNetCore.Docs

Modernize hosting-model code snippets in file-uploads.md to minimal hosting

Open
#37,641 0 comments 0 reactions 1 assignee Claimed by @tdykstra View on GitHub
:watch: Not Triaged aspnet-core/svc doc-enhancement doc-out-of-date mvc/subsvc
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 2h
Merged PRs (30d)
109

Description

## Description

Split out from review of #37600 to keep that PR scoped to its originating UUF issue (#36039).

The **Server and app configuration** section of `aspnetcore/mvc/models/file-uploads.md` mixes two hosting-model styles within the same `:::moniker range=">= aspnetcore-5.0":::` block:

* Existing snippets use the pre-3.0 style: `public void ConfigureServices(IServiceCollection services)`, `CreateHostBuilder` / `Host.CreateDefaultBuilder(...).ConfigureWebHostDefaults(...)`, and references to `Startup.ConfigureServices`.
* Snippets added in #37600 use minimal hosting: `builder.Services.Configure(...)`, `app.MapPost(...)`.

Since this content is scoped to ASP.NET Core 5.0 and later — and the project templates have used minimal hosting since 6.0 — the older snippets should be updated so the section reads consistently.

## Snippets to update

All in `aspnetcore/mvc/models/file-uploads.md`, within the `>= aspnetcore-5.0` moniker block:

- [ ] **Multipart body length limit** — `services.Configure` wrapped in `public void ConfigureServices(...)`
- [ ] **Multipart body length limit** — `services.AddRazorPages(options => ...)` convention example; prose references `Startup.ConfigureServices`
- [ ] **Kestrel maximum request body size** — `CreateHostBuilder` / `ConfigureWebHostDefaults` / `webBuilder.ConfigureKestrel` / `.UseStartup()`
- [ ] **Kestrel maximum request body size** — `services.AddRazorPages(options => ...)` `RequestSizeLimitAttribute` convention example; prose references `Startup.ConfigureServices`

Suggested target style, matching the rest of the article after #37600:

```csharp
var builder = WebApplication.CreateBuilder(args);

builder.Services.Configure(options =>
{
// Set the limit to 256 MB
options.MultipartBodyLengthLimit = 268435456;
});
```

```csharp
var builder = WebApplication.CreateBuilder(args);

builder.WebHost.ConfigureKestrel(options =>
{
// Handle requests up to 50 MB
options.Limits.MaxRequestBodySize = 52428800;
});
```

## Notes

* Update the surrounding prose that references `Startup.ConfigureServices` so it matches the minimal hosting snippets.
* Verify whether any of these need to remain in the older style for the `>= aspnetcore-3.0 < aspnetcore-5.0` and `2.1` moniker blocks — those blocks are separate and out of scope here.
* Bump `ms.date` when making the change.

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.