Questions tagged [system.net.webexception]

system.net.webexception is a .NET exception is thrown when an error occurs while accessing the network through a pluggable protocol.

system.net.webexception is a .NET exception is thrown when an error occurs while accessing the network through a pluggable protocol.

174 questions
362
votes
32 answers

No connection could be made because the target machine actively refused it?

Sometimes I get the following error while I was doing HttpWebRequest to a WebService. I copied my code below too. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made…
hsnkvk
  • 3,629
  • 2
  • 16
  • 4
51
votes
4 answers

System.Net.WebException: The remote name could not be resolved:

I am testing an endpoint that I am experiencing some issues with. I am simply using HttpClient in a loop that performs a request each hour. var httpClient = new HttpClient(); var message =…
Poul K. Sørensen
  • 16,950
  • 21
  • 126
  • 283
48
votes
3 answers

The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF, In WinForms?

I am trying to use a WebClient / HttpWebRequest to download some data from a server. I use the following code to do so: WebClient client = new WebClient(); client.Credentials = new NetworkCredential("admin", "password"); Stream datastream =…
msbg
  • 4,852
  • 11
  • 44
  • 73
26
votes
5 answers

Error 502 (Bad Gateway) when sending a request with HttpWebRequest over SSL

I have the following snippet in classic ASP, to send a command and retrieve the response over SSL: Dim xmlHTTP Set xmlHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0") xmlHTTP.open "POST", "https://www.example.com",…
Leonardo
  • 2,439
  • 6
  • 26
  • 27
26
votes
3 answers

Failure on HttpWebrequest with inner exception Authentication failed because the remote party has closed the transport stream

Using C#, .Net 4.5, I'm trying to send out a web request through HttpWebRequest on a remote server. Please see the code below. I tried most of the solutions suggested by some forums but I always end up with the same error. Please see the stack…
21
votes
4 answers

Difference between operation has time out and (504) Gateway Timeout

I am using HttpWebRequest in my application which is checking some URI's in multiple threads. I am getting multiple types of time out exceptions. The operation has timed out The remote server returned an error: (504) Gateway Timeout. Their…
user2711965
  • 1,795
  • 2
  • 14
  • 34
17
votes
7 answers

C# System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send

I'm getting this error on just one server running Windows Server 2003: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. Here's my code... Any ideas? HttpWebRequest request =…
Jon
  • 1,608
  • 7
  • 25
  • 38
15
votes
5 answers

System.Net.WebException: The request was aborted: the request was cancelled

I have a WCF service that has been giving me this error under load conditions (and I can't seem to recreate the error otherwise). We've been trying to find a way around it for about a week now with no such luck.. The error I see has two parts to…
15
votes
7 answers

WCF method called twice

I have a web service which is returning data to the desktop application. The problem I am having is, when the web service returns small volume of data everything works fine but when the volume of data is large it throws the following…
Saurabh Lalwani
  • 705
  • 2
  • 7
  • 15
14
votes
1 answer

WebException when reading a WebException's response stream

I'm communicating with a web server from .Net. The web server throws a 500 internal server error and writes a detailed error message. I'm trying to read the error message that is received from a web exception, but getting another web exception. Why…
ripper234
  • 222,824
  • 274
  • 634
  • 905
12
votes
3 answers

Which specific status codes cause a WebException to be thrown by HttpWebRequest.GetResponse()?

I've hunted around for some definitive documentation on this but haven't had much luck finding any. For which HTTP Response Status codes will HttpWebRequest.GetResponse() generate a WebException after doing something like a POST? Specifically, will…
H. Morrow
  • 151
  • 1
  • 5
10
votes
1 answer

System.Net.HttpWebResponse.GetResponseStream() returns truncated body in WebException

For some reason beyond my understanding requests made to a perticular website (https://learningnetwork.cisco.com/people/mrollins?view=profile) result in a reqsponse-object whose responsestream contain a trunkated version of the website. The stream…
Tor
  • 261
  • 2
  • 6
10
votes
2 answers

The request was aborted: The request was canceled. No solution works

Our console applications are making hundreds of WebRequests to Facebook every minute (with using multiple apps and hundreds of access tokens). Now, they started to fail with the exception message in the title ("The request was aborted: The request…
9
votes
6 answers

Getting "underlying connection was closed" on HttpWebRequest

I have an application written in VB.NET (NOT asp.net, it is a Windows Console app). I am trying to call a url (an html page) and get back the response into a string. The response is straight JSON, no html tags whatsoever. It opens with { and closes…
eidylon
  • 7,068
  • 20
  • 75
  • 118
6
votes
3 answers

Keep trying to talk to server when the Internet is down

So my application is exchanging request/responses with a server (no problems), until the internet connection dies for a couple of seconds, then comes back. Then a code like this: response = (HttpWebResponse)request.GetResponse(); will throw an…
Alex
  • 7,432
  • 20
  • 75
  • 118
1
2 3
11 12