Skip to content

HttpResponse.OnCompleted isn't working as expected #17268

Closed
@talalkhan

Description

@talalkhan

I have tested this defect on .net core 2.2 and 3.0. It's a bug when using IIS Express but it's working as expected when switch to Kestrel. OnCompleted doesn't fire after response.
Steps to reproduce:
Run the following code in IIS express and put the breakpoint on "await Task.Delay(2000); " line.
You will see the response is sent in the browser and then the following code is executed when using the Kestrel server but when you switch to IIS Express, the response is not sent in the browser.

  [HttpGet]
        public  string Get()
        {
            try
            {
           
                // Some work 
                return "talal";
            }
            finally
            {

                Response.OnCompleted(async () =>
                {
                    // Put breakpoint here
                    await Task.Delay(2000); 
                });
            }
        }

Metadata

Metadata

Assignees

Labels

area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsbugThis issue describes a behavior which is not expected - a bug.feature-iisIncludes: IIS, ANCMinvestigate

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions