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 to use HttpWebRequest with Cookies like Browser?

I'm fixing a module checking Google Keyword Ranking, each keywords for each 30s. Those day, Google block the request, the module is very important for our project. I'm using HtmlAgilityPack in my module, the code is something like…
2
votes
0 answers

Logging in to mint with C#

I want to get a csv file from mint.com and manipulate it in C#. I have to log in to do this. I have followed the suggestions of another post on Stack Overflow and have come up with the following code. Unfortunately, the result I get is not the…
2
votes
0 answers

C# How to force reusing authenticated Http connections?

I cant make my Http connections to be reused. HttpWebRequest.KeepAlive setting makes no difference. I found this article which says that if you have NTLM authentication then use UnsafeAuthenticatedConnectionSharing = true. So I set it to true and…
Boppity Bop
  • 9,613
  • 13
  • 72
  • 151
2
votes
1 answer

How to pass query parameters to the EntityQuery interface

The following link passes query parameters as f:param and they get substituted in Users.page.xml, and these parameters appear as query parameters in the browse URL which we would like to not show to the end user. Is there an alternate mechanism to…
user339108
  • 12,613
  • 33
  • 81
  • 112
2
votes
2 answers

How to print out the HttpWebRequest in C#?

I'm having a problem with a POST I'm doing using the HttpWebRequest object from C#. In order to analyze the problem I would like to know exactly what is being sent over the wire. The problem is that I'm also using HTTPS so I can't sniff the wire. I…
Alfred B. Thordarson
  • 4,460
  • 8
  • 39
  • 37
2
votes
1 answer

How to disable cache for asynchronous HTTPWebRequest for Windows Phone application?

I am developing a mobile app using Rest API. I'm using Asynchronous calls as GetResponse method is not supported in Windows Phone 8 development. When I launch the application, it fetches the correct data using GET method. I have implemented a 60…
2
votes
1 answer

How to do HTTPS with TcpClient just like HttpWebRequest does?

I've got a communication system based on TcpClient, and it works great except for when it's doing HTTPS to a particular IP. Then it starts to fail. By using a browser or HttpWebRequest, I have no problems doing HTTPS to that IP. I've created a test…
Task
  • 3,668
  • 1
  • 21
  • 32
2
votes
0 answers

Throwing a WebException while posting XML data using HttpWebRequest and HttpWebrequest in c#

I am trying to get a response xml from the UIDAI data centers by sending an xml document using HttpWebRequest and receiving it using HttpWebResponse in C#ASP.net web based application. I already checked it using a java application and it is working…
2
votes
1 answer

How do I get HttpWebRequest.GetResponse() to time out more slowly?

I'm dealing with an agitating server that takes a long time to send a response when I make a POST request. I can't use .NET 4.5, so I've been using HttpWebRequest and, more recently, WebClient. The server accepts some data via POST, takes a long…
OwenP
  • 24,950
  • 13
  • 65
  • 102
2
votes
1 answer

What is happening when you enter

First URL stands for Uniform Resource Locator. It will be very difficult to remember an IP address. Instead of remembering the IP addresses URL came like www.intrepidkarthi.com. Url normally contains three parts. For example…
intrepidkarthi
  • 3,104
  • 8
  • 42
  • 75
2
votes
1 answer

Setting the cookie container on a HttpWebRequest causes a timeout but the post goes through anyway

I have the following code CookieContainer container = new CookieContainer(); HttpCookieCollection oCookies = HttpContext.Current.Request.Cookies; for (int j = 0; j < oCookies.Count; j++) { …
Ross
  • 165
  • 2
  • 12
2
votes
5 answers

HttpWebRequest Server Unavailable 503 probleme

I originally used WebRequest and WebResponse to sent Http Post Messages. Always I got a response of "OK". The message I post is an XML signed with a certificate in the xml. The composition is this: C# service that is sending to a https…
ThorDivDev
  • 721
  • 2
  • 12
  • 22
2
votes
1 answer

Get data on error with HttpWebRequest

While interacting with an API there is a situation where they will return a 401 response that also contains data. I would like to return this data regardless of the error code of the response. I have created a function to submit a either a GET or…
Spaceman Spiff
  • 934
  • 1
  • 14
  • 32
2
votes
1 answer

HttpWebRequest results in “The request was aborted: Could not create SSL/TLS secure channel” and returned code=AlgorithmMismatch

As mentioned in this post, I have exactly the same error in network logs (returned code=AlgorithmMismatch) except I use ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 to avoid POODLE vulnerability, the regkey has been set to 1…
Edd M
  • 31
  • 4
2
votes
0 answers

IOException reading from HttpWebResponse response stream over SSL

I get the following exception when attempting to read the response from my HttpWebRequest: System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream. at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32…
Redwood
  • 66,744
  • 41
  • 126
  • 187