Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
While working on #58233 I tested a scenario with controller-based endpoint handler which has CancellationToken
parameter and handles the big file upload:
// curl -X POST -F "file=@D:\.other\big-files\bigfile.dat" http://localhost:5000/file/upload
[HttpPost]
[Route("upload")]
public async Task<IActionResult> UploadCts(CancellationToken cancellationToken)
{
...
}
I spotted that because of having any parameter forces model binding, and it eventually calls FormValueProviderFactory.AddValueProviderAsync.
Such behavior means that user cannot for example stream the request body to file stream (if that is the intention).
Accessing and reading from HttpRequest.BodyReader clearly shows that body is already read.
Even for parameter like [FromQuery] string id
the same behavior exists:
// curl -X POST -F "file=@D:\.other\big-files\bigfile.dat" http://localhost:5000/file/upload
[HttpPost]
[Route("upload/{id}")]
public async Task<IActionResult> UploadQueryParam([FromQuery] string id)
{
return Ok($"Query completed: query id = {id}");
}
Expected Behavior
I think aspnetcore should not read the body of the request allowing user to control when that should be happening.
Steps To Reproduce
Exceptions (if any)
No response
.NET Version
net9.0
Anything else?
No response