So I'm thinking about a functionality where the user pastes a link and the server-side code crawls the provided link and responds with the contents of that link (such as page title, description, thumbnail, etc).
The user can meanwhile change the link, and in doing that, the ajax-request should be aborted client-side.
I'm wondering what exactly happens in the IIS server and specifically to my C# code.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With