What happens in IIS/C# when a request is aborted What happens in IIS/C# when a request is aborted ajax ajax

What happens in IIS/C# when a request is aborted


If the server code checks the state of Response.IsClientConnected, it can stop the work and produce an empty response when the client aborts the request, otherwise it will just complete the request as usual.

The request handling will not be aborted automatically just because there is noone waiting for it any more. The server code has to actively check the state of the request.


Your web server doesn't know that the client cancelled the request. The request will still be fulfilled and a response will be sent back. The client-side script that you write will need to be able to handle what the current state of your page should be.

If you are certain that you don't care about the response, I would recommend aborting the request client-side:

xhr.abort()


If you close the connection client side before the response is written an error stating as much is thrown. You could just choose not to handle the response when it comes back from the server.