Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 30, 2025

Fixes #36060

Summary

This PR adds clarification to the minimal APIs documentation regarding IFormFile binding requirements in response to user feedback indicating confusion about whether form encoding is required or if the entire request body can be interpreted as the file.

Problem

Users were unclear about the requirements for using IFormFile in minimal APIs, specifically:

  • Whether multipart/form-data encoding is mandatory
  • Whether the entire request body can be bound directly to an IFormFile parameter
  • How parameter names relate to form field names

Changes

Added explicit clarification to the "File uploads using IFormFile and IFormFileCollection" section in the parameter binding documentation for ASP.NET Core 8.0-10.0:

Added text:

File uploads using IFormFile and IFormFileCollection in minimal APIs require multipart/form-data encoding. The parameter name in the route handler must match the form field name in the request. Minimal APIs don't support binding the entire request body directly to an IFormFile parameter without form encoding.

This clarification is placed immediately before the code example to ensure developers understand the requirements before implementing file uploads.

Files Modified

  • aspnetcore/fundamentals/minimal-apis.md - Updated ms.date to 10/22/2025
  • aspnetcore/fundamentals/minimal-apis/includes/parameter-binding8-10.md - Added IFormFile binding clarification for ASP.NET Core 8.0-10.0 (consolidated parameter binding documentation)

Validation

  • Markdown lint validation passed with no new errors introduced
  • Changes are minimal and surgical (32 insertions, 3 deletions across 2 files)
  • Targets ASP.NET Core 8.0, 9.0, and 10.0 documentation in the consolidated parameter-binding8-10.md file
Original prompt

This section details on the original issue you should resolve

<issue_title>UUF: Minimal-APIs: Add IFormFile binding information</issue_title>
<issue_description>### Description

Add IFormFile binding information to minimal APIs documentation

User feedback transferred from UUF System:

"IFormFile does not specify if the caller MUST use form encoding, or if simply interprets the entire body as the file"

The following Problem/Solution is just an AI generated recommendation and should be treated as such:

Problem Statement

The minimal APIs documentation currently does not include information about using IFormFile for file uploads. Specifically, it lacks details about whether form encoding is required when using IFormFile or if the entire request body can be interpreted as the file. This is important information for developers implementing file upload functionality in minimal APIs.

Proposed Solution

Add a section about file uploads with IFormFile to the parameter binding section of the minimal APIs documentation. This section should clarify:

  1. That multipart/form-data encoding is required when using IFormFile
  2. The supported request formats and parameter binding patterns
  3. Examples of implementing file uploads in minimal API endpoints

Suggested Changes

Add the following content to the Parameter binding section around line 153 (after the parameter binding include directive):

File uploads with IFormFile

When using IFormFile in minimal APIs, the following requirements and formats apply:

Request format requirements:

  • Form encoding is required: Requests must use multipart/form-data encoding when uploading files with IFormFile
  • The parameter name in your endpoint must match the form field name in the request
  • Unlike controller-based APIs, minimal APIs do not support binding the entire request body directly to an IFormFile parameter

Example implementations:

Single file upload:
app.MapPost("/upload", async (IFormFile file) =>
{
    var tempFile = Path.GetTempFileName();
    using var stream = File.OpenWrite(tempFile);
    await file.CopyToAsync(stream);
    
    return Results.Ok(new { 
        FileName = file.FileName,
        Length = file.Length,
        TempPath = tempFile
    });
});

### Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis?view=aspnetcore-9.0

### Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/minimal-apis.md

### Document ID

b09824ab-b051-75a1-13b7-b0e281cc46e0

### Platform Id

24c01f0e-630a-08a5-698d-9668e1a7b40e

### Article author

@wadepickett

### Metadata

* ID: b09824ab-b051-75a1-13b7-b0e281cc46e0
* PlatformId: 24c01f0e-630a-08a5-698d-9668e1a7b40e 
* Service: **aspnet-core**
* Sub-service: **fundamentals**

[Related Issues](https://github.com/dotnet/AspNetCore.Docs/issues?q=is%3Aissue+is%3Aopen+b09824ab-b051-75a1-13b7-b0e281cc46e0)</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>
Fixes #36060

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Internal previews

📄 File 🔗 Preview link
aspnetcore/fundamentals/minimal-apis.md Minimal APIs quick reference

Copilot AI changed the title [WIP] UUF: Minimal-APIs: Add IFormFile binding information Add IFormFile binding information to minimal APIs documentation Sep 30, 2025
Copilot AI requested a review from wadepickett September 30, 2025 22:06
Copilot finished work on behalf of wadepickett September 30, 2025 22:06
@tdykstra tdykstra added the reQUEST Triggers an issue to be imported into Quest label Sep 30, 2025
@wadepickett wadepickett removed the reQUEST Triggers an issue to be imported into Quest label Oct 23, 2025
@wadepickett
Copy link
Contributor

@copilot,
Revert the following file changes in this PR for the following files so these files are not part of the changes in this PR:
aspnetcore/fundamentals/minimal-apis/includes/parameter-binding9.md
aspnetcore/fundamentals/minimal-apis/includes/parameter-binding8.md
aspnetcore/fundamentals/minimal-apis/includes/parameter-binding7.md

Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@copilot,
Revert the following file changes in this PR for the following files so these files are not part of the changes in this PR:
aspnetcore/fundamentals/minimal-apis/includes/parameter-bindin...

Reverted the changes to the three files as requested. Commit: 780b4e4

The PR now only includes changes to:

  • aspnetcore/fundamentals/minimal-apis.md (ms.date update)
  • aspnetcore/fundamentals/minimal-apis/includes/parameter-binding10.md (IFormFile binding clarification)

Copilot AI requested a review from wadepickett October 23, 2025 04:07
Copilot finished work on behalf of wadepickett October 23, 2025 04:07
@wadepickett
Copy link
Contributor

@copilot, this file in this PR:
aspnetcore/fundamentals/minimal-apis/includes/parameter-binding10.md

Needs its name to change to match the changed name in the main branch. Rename the file to this:
aspnetcore/fundamentals/minimal-apis/includes/parameter-binding8-10.md

Copy link
Contributor Author

Copilot AI commented Oct 23, 2025

@copilot, this file in this PR:
aspnetcore/fundamentals/minimal-apis/includes/parameter-binding10.md

...

Renamed the file from parameter-binding10.md to parameter-binding8-10.md to match the main branch structure. Commit: 59eeff5

The file now includes the IFormFile binding clarification and aligns with the consolidated parameter binding documentation for ASP.NET Core versions 8.0-10.0.

Copilot finished work on behalf of wadepickett October 23, 2025 04:15
@wadepickett wadepickett marked this pull request as ready for review October 23, 2025 05:23
Copy link
Contributor

@mikekistler mikekistler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍

@wadepickett wadepickett merged commit ec629ec into main Oct 27, 2025
3 checks passed
@wadepickett wadepickett deleted the copilot/fix-f05dea14-995e-4ae2-b8a3-08aba9e2c7a2 branch October 27, 2025 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UUF: Minimal-APIs: Add IFormFile binding information

4 participants