Will calling HttpResponse.WriteAsync() cause HttpResponse.HasStarted to be set to true
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
I am observing the following behavior when running my webapp in using dotnet core 3.1
var b = response.HasStarted // b is false
response.WriteAsync("hello").Wait();
b = response.HasStarted // b is true
where response
is of type Microsoft.AspNetCore.Http.HttpResponse
Is this the intended behavior? Is this how .Net Framework worked?
According to https://learn.microsoft.com/en-us/aspnet/core/fundamentals/use-http-context?view=aspnetcore-7.0 “A response is started by flushing the response body or calling HttpResponse.StartAsync”
Yet if I step through the code it looks like I am doing neither.
Expected Behavior
response.WriteAsync
does not cause response.HasStarted
to be true
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
dotnet core 3.1
Anything else?
No response
Issue Analytics
- State:
- Created 9 months ago
- Reactions:1
- Comments:11 (8 by maintainers)
Top Results From Across the Web
what's HttpContext.Response.HasStarted for?
Server.Response.HasStarted : Indicates if the response status, reason, and headers are prepared to send and can no longer be modified. This is ...
Read more >Use HttpContext in ASP.NET Core
StartAsync(CancellationToken). The HttpResponse. HasStarted property indicates whether the response has started.
Read more >Content Injection with Response Rewriting in ASP.NET Core 3.x
In this post I discuss how to intercept Response output by using a customized stream, ... The reason for this suggestion is that...
Read more >Handling errors in ASP.NET Core Web API - DevTrends
This post looks at the best ways to handle exceptions, validation and other invalid requests such as 404s in ASP.NET Core Web API...
Read more >Middleware
If the response has not started ( HttpResponse.HasStarted ) it can be cleared ( HttpResponse.Clear() ) and an alternate response sent, or the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@orange-puff take a look at https://github.com/dotnet/systemweb-adapters