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

HttpWebRequest use VPN(just like proxy)

So my question is if there is possibility to use VPN instead of Proxy in HttpWebRequest? I need to make voting program, but all public proxies are slow or unreliable. Just like this: request.Proxy = new WebProxy("127.0.0.1", 8080);
Immons
  • 257
  • 1
  • 11
2
votes
1 answer

.NET 4.5 HTTPWebRequest - Intermittent slowdowns with a large number of simultaneous HTTPS POST requests

I have a large number (50+) of threads which make HTTPS POST requests to a web api to poll different data sets as fast as possible. It works fine half of the time, but for the other half there will be a hiccup where the bandwidth used by the…
Matt
  • 774
  • 1
  • 10
  • 28
2
votes
2 answers

How to connect but wait to send any header using HttpWebRequest?

I want to make a https request BUT I want to initiate the connection first without sending the headers, even the GET /something/ HTTP/1.1 part. In other words I want to keep the connection ready and send everything as soon as I'm done. I would have…
gunakkoc
  • 1,069
  • 11
  • 30
2
votes
3 answers

HttpWebRequest async versus Begin/End

I have a Web API project whose controller in turn makes web requests to a third party REST interface. My controller CRUD functions i have marked as async however the implementation is such that i use HttpWebRequest blocking functions…
user1371314
  • 762
  • 7
  • 24
2
votes
2 answers

can I download a file over http that have a space in the name? (ruby)

there is a space after the word Part in the file name I want to download. It looks like http.get doesn't pass the url_path correctly because you can download the file from the browser without any troubles. any suggestion how I can download a file if…
Radek
  • 13,813
  • 52
  • 161
  • 255
2
votes
1 answer

Add File to Post Data to Page

I have Windows application, and I want to post data to an Url to get information from a webservice. This is the code I use: private string PostData(string url, string postData) { HttpWebRequest request = null; if (m_type ==…
alhambra eidos kiquenet
2
votes
2 answers

HttpWebRequest to SSL fails

I'm using this code, to make a request to a given URL: private static string GetWebRequestContent(string url) { string sid = String.Empty; HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); req.KeepAlive = false; using…
MartinHN
  • 19,542
  • 19
  • 89
  • 131
2
votes
1 answer

HttpWebRequest always show the same result C#

First thank you for the help.I have a problem which makes me crazy... In fact, I make a GET request in my web service that I made, and it works fine, for one time. If I do THE SAME request after, the request doesn't reach my web service. The result…
Pierre F
  • 81
  • 1
  • 8
2
votes
2 answers

Why does a link with "@" work in my browser but C# HttpWebRequest gives 404 (The remote server returned an error: (405) Method Not Allowed.)

Anyone have an idea offhand regarding why a link with an "@" in it works on my browser, but when I go to get this particular link in my HttpWebRequest code I get a 405 error? The remote server returned an error: (405) Method Not Allowed. The…
Greg
  • 34,042
  • 79
  • 253
  • 454
2
votes
1 answer

Does the WebResponse for Windows Phone 8 skip set-cookie headers

I am experiencing some strange behavior with a Windows Phone 8 app that I am building and I hope someone here has some experience with it. I am reading a website using a normal HttpWebRequest and expecting a cookie as a response. However, somehow, I…
sTodorov
  • 5,435
  • 5
  • 35
  • 55
2
votes
0 answers

HttpWebRequest creates request on Non-KeepAlive pipeline

I've been facing a unique problem for a while now. Our web servers runs under constant load (approx 500 Request Per Second) throughout the day. And we also make outbound call our external API. Problem: I see about 9k-10k TIME_WAIT connections to my…
S14df
  • 125
  • 1
  • 9
2
votes
1 answer

How to send cookie with HttpWebRequest in c#

I've made short program with 6 textbox that I manually fill in with cookies. Now I want my program to act on specific url as if its logged in. How can I get that ? I tried this and I get http response that I'm not logged in. string url =…
user3399805
  • 39
  • 1
  • 9
2
votes
2 answers

C# HttpWebRequest - PreAuthenticate: Still returns 401 forbidden (HTTPS)

I would like to ask you for help with the following code I have quickly write, beucase I always get "403 FORBIDDEN". HttpWebRequest pozadavek = (HttpWebRequest)WebRequest.Create("LINK THAT ASKS FOR AUTHLOGIN"); //https System.IO.StreamReader…
Snake
  • 309
  • 2
  • 5
  • 10
2
votes
1 answer

String encoding problem on PdoStatement->bindParam()?

I'm trying to perform a simple SELECT statement from a string taken from a $_REQUEST var but it seem my PDO statement doesn't like the string format, why? My $_REQUEST var contains a string like Hello+World, so I need to replace + with whitespaces…
vitto
  • 19,094
  • 31
  • 91
  • 130
2
votes
3 answers

Download .xls file from a url

I'm trying to download an xls file from a url: http://www.site.com/ff/excel/file.aspx?deven=0 I'm using this code but when the download is complete the file is not properly downloaded. How can I download this file correctly? string…
user3311989
  • 21
  • 1
  • 1
  • 2
1 2 3
99
100