Questions tagged [httpwebrequest]

HttpWebRequest is a concrete class for .NET Framework applications that provides an HTTP-specific implementation of the abstract WebRequest class. Related tag: [webrequest].

The HttpWebRequest class provides support for the properties and methods defined in WebRequest and for additional properties and methods that enable the user to interact directly with servers using HTTP.

Do not use the HttpWebRequest constructor. Use the WebRequest.Create method to initialize new HttpWebRequest objects. If the scheme for the Uniform Resource Identifier (URI) is http:// or https://, Create returns an HttpWebRequest object.

The GetResponse method makes a synchronous request to the resource specified in the RequestUri property and returns an HttpWebResponse that contains the response. You can make an asynchronous request to the resource using the BeginGetResponse and EndGetResponse methods.

When you want to send data to the resource, the GetRequestStream method returns a Stream object to use to send data. The BeginGetRequestStream and EndGetRequestStream methods provide asynchronous access to the send data stream.

For client authentication with HttpWebRequest, the client certificate must be installed in the My certificate store of the current user.

The HttpWebRequest class throws a WebException when errors occur while accessing a resource. The WebException.Status property contains a WebExceptionStatus value that indicates the source of the error. When WebException.Status is WebExceptionStatus.ProtocolError, the Response property contains the HttpWebResponse received from the resource.

HttpWebRequest exposes common HTTP header values sent to the Internet resource as properties, set by methods, or set by the system; the following table contains a complete list. You can set other headers in the Headers property as name/value pairs. Note that servers and caches may change or add headers during the request.

You can find the documentation for the class on MSDN.

5585 questions
2
votes
0 answers

How does ServicePointManager.DefaultConnectionLimit relate to HttpWebRequest?

I'm wondering how does ServicePointManager.DefaultConnectionLimit relate to the HttpWebRequest. Let's say I set the ServicePointManager.DefaultConnectionLimit = 10 and then I create 20 threads that all need to send a request to the same url. Will…
Svet Angelov
  • 799
  • 8
  • 19
2
votes
1 answer

Xamarin Android HttpWebClient with certificate: System.IO.IOException: The authentication or decryption has failed

We are developing an Android Application using Xamarin. The application sends working data to a backend service (WCF secured with certificate) via HttpWebRequest Post on HTTPS. Everything works fine until the message sent exceed a limit size. In…
2
votes
1 answer

HttpWebRequest: Could not establish Trust Relationship for SSL - Self Signed Certificate already added to Trusted Root CA

"Exception thrown: 'System.Net.WebException' in System.dll Additional information: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel." I have added/imported my self-signed certificate to…
xyfer
  • 63
  • 1
  • 6
2
votes
3 answers

How to send .csv file with post Web Request in C#

I want to send .csv file in a POST request where content type is "multipart/form-data" and in the body there is some key and the .csv file Below is the code I have tried: string url = "*****URL*****"; string root =…
Indranil
  • 2,229
  • 2
  • 27
  • 40
2
votes
2 answers

Checking if URL exists - HTTP Request always returns an exception

There are numerous posts on how to check if a URL is valid. All of them feature basically the same code, which seems to work for everyone - not for me though and I don't get why. public static bool ifURLexists(string url) { try …
user6154614
2
votes
1 answer

Can I detect image request by HTTP headers?

Well, I would like to know if it's possible to detect by HTTP headers if request comes from
confiq
  • 2,795
  • 1
  • 26
  • 43
2
votes
2 answers

SSL/TSL Secure Channel exception while sending HttpWebRequest

I have a download method in C#. The method sends request to the URL to be downloaded. But it gives error for some URL address. The last URL that has problem I faced is an exe file link. My method: void DownloadProcedure() { #region…
Ali Tor
  • 2,772
  • 2
  • 27
  • 58
2
votes
1 answer

HttpWebRequest support for named pipes?

To all the .NET experts, I have a question for you. I need to do SOAP/HTTP over named pipes on Windows, in C#. (This is for a client talking to a Python library/server using SOAP for RPC. Using socket/port was deemed both insecure, and port…
Evan Chan
  • 21
  • 1
2
votes
3 answers

Understanding SSL connections with .NET's HttpWebRequest

I can't seem to get my head around this one. I'm using HttpWebRequest to try and send some data out to another site. I'm attempting to figure out the best way to get our firewalls configured, but I'm at a loss. By watching the NetMon trace, it…
Chris
  • 4,030
  • 4
  • 47
  • 76
2
votes
2 answers

Disable image download for HttpWebRequest

Is it possible to say a webrequest to only get text-based data from a site? And if it is how should I do this? The only thing I can imagine is to search in the response string and remove all the image-tags. But this is a very bad way to do…
Snickbrack
  • 1,253
  • 4
  • 21
  • 56
2
votes
0 answers

Not able to remove Connection header from Http request created by httpwerequest class

I want to remove Connection header from my multipart upload request.But it is not getting removed even though I am setting HttpWebrequest.Connection property to null.I have also checked at runtime, the value is null.I tried changing the value at…
V K
  • 1,645
  • 3
  • 26
  • 57
2
votes
4 answers

Trying to read non-ending byte stream asynchronously in C#

I am connecting to a server which sends updates about financial information. The code I post below will work correctly for a few minutes then usually blows up when it tries to do an EndRead (where I have noted), because there was 0 bytes at that…
Beaker
  • 2,804
  • 5
  • 33
  • 54
2
votes
0 answers

fiddler not detecting android emulator http requests

I am using android studio emulator api22(lollipop) and Telerik Fiddler Web Debugger (v4.6.2.30081) I have followed this to make fiddler detect android http requests from browser. But fiddler is not detecting requests even after following all the…
Anil P Babu
  • 1,235
  • 3
  • 26
  • 47
2
votes
3 answers

How can I check the progress of a HttpWebRequest upload?

I wonder how do I check how much of a file has been uploaded/downloaded? I am using HttpWebRequest
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
2
votes
1 answer

Logging into Ebay with C#

I am trying to log into my EBay account using C#. I have looked at various posts and found the following 3 options. Unforunately, none of them are working. I am also listing the response header values that I get and that Fiddler shows when doing a…
Atomic Star
  • 5,427
  • 4
  • 39
  • 48