-
We have a need to force close connections from the server every once in a while. The way we do this is by setting the connection close header when needed. Something like this (in this example we send connection close to all requests) public void UseConnectionCloseMiddleware(IApplicationBuilder app)
{
app.Use(
async (context, next) =>
{
// setting Connection Header to 'close' for closeConnectionPercentage% of the connections
context.Response.Headers.Add("Connection", "close");
await next.Invoke();
});
} This works fine when we run the service with kestrel. The moment IIS comes into the picture, it looks like IIS removes this header and does not send it back to the caller. Is there a way to stop IIS from doing this? I tried InProcess and OutOfProcess hosting models and both don't support this functionality. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Did you confirm the client is using HTTP/1.1 for these requests? That trick won't work for HTTP/2 (except on Http.Sys). |
Beta Was this translation helpful? Give feedback.
Did you confirm the client is using HTTP/1.1 for these requests? That trick won't work for HTTP/2 (except on Http.Sys).