Skip to content

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

Description

@tdykstra

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:

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 limitservices.Configure<FormOptions> wrapped in public void ConfigureServices(...)
  • Multipart body length limitservices.AddRazorPages(options => ...) convention example; prose references Startup.ConfigureServices
  • Kestrel maximum request body sizeCreateHostBuilder / ConfigureWebHostDefaults / webBuilder.ConfigureKestrel / .UseStartup<Startup>()
  • Kestrel maximum request body sizeservices.AddRazorPages(options => ...) RequestSizeLimitAttribute convention example; prose references Startup.ConfigureServices

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

var builder = WebApplication.CreateBuilder(args);

builder.Services.Configure<FormOptions>(options =>
{
    // Set the limit to 256 MB
    options.MultipartBodyLengthLimit = 268435456;
});
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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions