The case of the duplicate ASP.Net request

26 January 2019

A while ago I moved my sites to a new hosting environment, not only to a Windows Server 2016 but also a different data center with a different hosting and network environment. The migration worked pretty well, I set up my servers using mostly PowerShell scripts and everything seemed to work fine.

But then I noticed that when creating a new item on the site, two records were created in the database, that never happened before! Using F12 in the browser I could see that only a single http request was sent to the server. On the server however I could see two entries in the http logs, in my database access logs and of course the database itself. What's happening here?

I enabled failed request tracing and here as well there are two records for two requests! There are pretty much exactly the same until the very end.

The first request ends with these two entries:

224.GENERAL_FLUSH_RESPONSE_ENDBytesSent="0", ErrorCode="An operation was attempted on a nonexistent network connection. (0x800704cd)"
225.GENERAL_REQUEST_ENDBytesSent="0", BytesReceived="1271", HttpStatus="200", HttpSubStatus="0"

while the second request has:

224.GENERAL_FLUSH_RESPONSE_ENDBytesSent="486", ErrorCode="The operation completed successfully. (0x0)"
225.GENERAL_REQUEST_ENDBytesSent="486", BytesReceived="1271", HttpStatus="200", HttpSubStatus="0"

So the first requests finishes with an error and while it claims an http status of 200 it sent 0 bytes, so pretty much no response, instead the request got repeated and the second time it work and a proper http response was sent.

So why does this happen?

The "An operation was attempted on a nonexistent network connection. (0x800704cd)" doesn't really make any sense, or does it? I looked around and it comes up in some other scenarios with large data sizes and timeouts, but here I am only submitting some bytes of json data.

I checked other parts of my site, it happens whenever I submit some data via XHR (AJAX), edit and delete operations are affected as well, but only the insert operation results in a visible (duplicate record) problem. Submitting an old school ASP.NET web form, doesn't show this problem.

Some other people did blame their anti-virus software for similar problems, so I uninstalled Windows Defender from the server, but this didn't help.

I then removed all URL Rewrite rules from the site, but the problem persisted.

I run with a very stripped-down and hardened IIS, I tried to reproduce the problem with a similar configuration on my DEV machine and couldn't see it. With the network error in mind, I tested the site with a browser on the server itself and the problem did not occur, Ha! So it is indeed something with the network rather than the OS, IIS or my application?

The problem is, I have no control whatsoever over the hosting and networking environment.

I searched again online and found a question on StackOverflow that also mentioned the 0x800704cd error. While the accepted answer was to disable AVG Security software, a zero vote answer mentioned they disabled Client Certificates.

Worth a try, as I do support those as a means of authentication, and bang, by changing them from Accept to Ignore, the duplicate requests stopped happening.

I still want to support client certs, but I can just enable them for the logon section of the site, not for any other pages.

So I got a workaround for my problem but I still don't know why this happens with client certificates enabled. Why do ajax requests fail the first time and are repeated and then succeed? I guess this is a combination of things, because in my old hosting environment this worked fine.

Tags: ASP.Net | IIS

Pages in this section

Categories

ASP.Net | Community | Development | IIS | IT Pro | Security | SQL (Server) | Tools | Web | Work on the road | Windows