-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When returning a stream as a file while creating a web API, the stream is disposed twice.
Expected Behavior
The stream should only be disposed once.
Steps To Reproduce
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
var app = builder.Build();
app.Map("/test", () =>
{
var stream = new MyStream();
return Results.File(stream);
});
app.Run();
internal class MyStream : MemoryStream
{
private int _count;
protected override void Dispose(bool disposing)
{
_count++;
Console.WriteLine(_count);
base.Dispose(disposing);
}
}I can also reproduce while using FileStreamResult.
Exceptions (if any)
No response
.NET Version
9.0.101
Anything else?
There is no stack trace.
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etc