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
3 answers

HTTPWebRequest Could not create SSL/TLS secure channel

I am trying to call a Web API using HttpWebRequest(Console Application). To upload the file, I am using the code snippet provided by @Cristian Romanescu ont this question Upload files with HTTPWebrequest (multipart/form-data) If I set the…
Magellan
  • 71
  • 1
  • 2
  • 11
2
votes
0 answers

Can't create workitem via webrequest in RTC

I'm trying to create a .NET web application integration with RTC, where I would insert new workitems using RTC change management services, as defined in this article (specifically in "Create a Change Request"). I was able to get the URL-to-be-used…
thiagoprzy
  • 411
  • 2
  • 8
  • 21
2
votes
2 answers

Sending an Async Post WebRequest, I get a (411) Length Required

I am using the code below to post to a web site but I get a 411 error, ( The remote server returned an error: (411) Length Required). This is the function I am using, I just removed the exception handling. I get a WebException been thrown. private…
Simon Goodman
  • 1,174
  • 1
  • 8
  • 35
2
votes
1 answer

Microsoft Edge add http request header on virtual box

I have a mac, I need to test my website on Microsoft Edge in Windows using a virtual box. I want to add some http request headers to the call. However, I only found…
Sarah Zhou
  • 21
  • 1
  • 2
2
votes
1 answer

I can't add a variable into WebRequest in c#

I am trying to do a searching application like sociall.net in c# console. My purpose is , i will get a name and surname from user , and my application will search this name and surname on Google. i tried this code : …
Emre
  • 53
  • 6
2
votes
2 answers

C# Ebay API Post-Order check_eligibility using HttpWebRequest

I'm trying to use the check_eligibility call from the eBay Post-Order API in C# very unsuccessfully. Every time I get a bad response. Here is one way I've tried: string url = "https://api.ebay.com/post-order/v2/cancellation/check_eligibility"; …
Roro
  • 311
  • 2
  • 20
2
votes
1 answer

Do requests in UIWebView use sharedHTTPCookieStorage?

From googling a bit, the answer to my question is "yes". But how do I test that? I tried to inpsect the HTTP request headers (i.e. [request allHTTPHeaderFields]) in webView:shouldStartLoadWithRequest:navigationType:, but none of the request has the…
William Niu
  • 15,798
  • 7
  • 53
  • 93
2
votes
1 answer

Custom NTLM authentication with HttpWebRequest

I need to authenticate to a server which exposes a custom NTLM-based authentication scheme, using the standard HttpWebRequest object. It's pretty much basic NTLM except that during the NTLM handshake protocol I receive a cookie from the server which…
Tudor Olariu
  • 1,318
  • 1
  • 11
  • 18
2
votes
1 answer

What is RequestCacheLevel.BypassCache internally?

The documentation on RequestCacheLevel.BypassCache doesn't explain much on the internal working of setting this with HttpWebRequest. Some questions I have on it: What cache is this refering to? A previous comment which implies it shares with…
Robert MacLean
  • 38,975
  • 25
  • 98
  • 152
2
votes
3 answers

Is it possible to return the result of a HttpWebRequest POST method via IObservable interface

I'm trying in a single method to return the result of a HttpWebRequest POST method via the Reactive interface IObservable. I've managed to do this for a GET method using the code below: var request =…
AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152
2
votes
1 answer

Throttle WebRequests

I want to execute a bunch of WebRequests, but set a threshold on how many can be started simultaneously. I came across this LimitedConcurrencyTaskScheduler example and tried to utilize it like so scheduler = new…
Chris
  • 679
  • 1
  • 11
  • 26
2
votes
1 answer

Share current session on a new HttpWebRequest

I have already read many articles about the topic but I can't find solution. So please don't mark this question as duplicate because other solutions won't work and are out to date. I have a web application with a page containing a GridView (one…
Emanuele
  • 648
  • 12
  • 33
2
votes
1 answer

Not being able to get cookie from a redirect response

I'm trying to call an api auth method, which doesn't provide the session id in json, rather it redirects to some other page and provide the session id as cookie. Here is what the site owner suggested me to do: • Configure your client not to follow…
Badhon Jain
  • 938
  • 6
  • 20
  • 38
2
votes
4 answers

HTTP File upload boundary choice

So I am currently studying HTTP file uploads (in the context of using a HttpWebRequest to upload some files to an external API) and generally I see a few dozen dashes being used as the boundary. Browsers seem to usually add a randomly chosen…
Stigma
  • 1,686
  • 13
  • 27
2
votes
1 answer

How Request and Response will got process in service stack?

I am using service stack to build the create RESTful services, not have depth knowledge of it. This works as sending request and getting response back. I have scenario and my question is depends on it. Scenario: I am sending request from browser or…
Ravindra Sinare
  • 675
  • 1
  • 9
  • 25