[ Stack Overflow ] – c# – httpWebRequest (The underlying connection was closed: The connection was closed unexpectedly.)

In beginning coding in C# DotNet, we usually come across such errors, and it’s good to look into them, see link below for more details

c# – httpWebRequest (The underlying connection was closed: The connection was closed unexpectedly.) – Stack Overflow

.NET has a bug where it expects that the server will include a Connection: close response header if it will close the connection after the response is complete. If the server closes the connection without the Connection: Close header (entirely valid per RFC2616), .NET will encounter the closed connection when attempting to send the next request on the connection and it will throw this exception. What .NET should be doing is silently creating a new connection and resending the request on that new connection.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s