Questions tagged [httpwebresponse]

Provides an HTTP-specific implementation of the WebResponse class

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

1062 questions
22
votes
3 answers

C#: "Using" Statements with HttpWebRequests/HttpWebResponses

Jon Skeet made a comment (via Twitter) on my SOApiDotNet code (a .NET library for the pre-alpha Stack Overflow API): @maximz2005 One thing I've noticed just from browsing the source quickly: you don't disposed (sic) of WebResponses. "using"…
Maxim Zaslavsky
  • 17,787
  • 30
  • 107
  • 173
22
votes
2 answers

GetResponseAsync does not accept cancellationToken

It seems that GetResponseAsync does not accept cancellationToken in Async/Await. So the question is how can I cancel the below procedure, provided I need to collect Cookies from response: using (HttpWebResponse response = (HttpWebResponse) await…
Jim
  • 2,760
  • 8
  • 42
  • 66
21
votes
9 answers

HTTPWebResponse + StreamReader Very Slow

I'm trying to implement a limited web crawler in C# (for a few hundred sites only) using HttpWebResponse.GetResponse() and Streamreader.ReadToEnd() , also tried using StreamReader.Read() and a loop to build my HTML string. I'm only downloading pages…
Roey
  • 849
  • 2
  • 11
  • 20
21
votes
4 answers

Getting the Response of a Asynchronous HttpWebRequest

Im wondering if theres an easy way to get the response of an async httpwebrequest. I have already seen this question here but all im trying to do is return the response (which is usually json or xml) in the form of a string to another method where i…
gdp
  • 8,032
  • 10
  • 42
  • 63
20
votes
7 answers

How to get cookies info inside of a CookieContainer? (All Of Them, Not For A Specific Domain)

Please see the code below: CookieContainer cookieJar = new CookieContainer(); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com"); request.CookieContainer = cookieJar; HttpWebResponse response =…
SilverLight
  • 19,668
  • 65
  • 192
  • 300
17
votes
2 answers

Logging Into A Website Using C# Programmatically

So, I've been scouring the web trying to learn more about how to log into websites programmatically using C#. I don't want to use a web client. I think I want to use something like HttpWebRequest and HttpWebResponse, but I have no idea how these…
DGarrett01
  • 391
  • 1
  • 2
  • 13
15
votes
4 answers

When to call WebResponse.Close()

WebResponse response; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Timeout = 20000; response = request.GetResponse(); request = (HttpWebRequest)WebRequest.Create(url2); response =…
Sameet
  • 2,191
  • 7
  • 28
  • 55
14
votes
6 answers

How To Use HttpWebRequest/Response To Download A Binary (.exe) File From A Web Server?

I am writing a program that needs to download an .exe file from a website and then save it to the hard drive. The .exe is stored on my site and it's url is as follows (it's not the real uri just one I made up for the purpose of this…
Jan Tacci
  • 3,131
  • 16
  • 63
  • 83
13
votes
1 answer

Getting full response body from System.Net.WebRequest

I'm using System.Net.WebRequest to get info from some API. When I get an error, the response contains only the basic HttpStatusCode and message, and not the full error returned. For comparison, running the same post data and headers in a tool such…
AlexD
  • 4,062
  • 5
  • 38
  • 65
12
votes
3 answers

HttpWebResponse won't scale for concurrent outbound requests

I have an ASP.NET 3.5 server application written in C#. It makes outbound requests to a REST API using HttpWebRequest and HttpWebResponse. I have setup a test application to send these requests on separate threads (to vaguely mimic concurrency…
erasend
  • 123
  • 1
  • 4
12
votes
8 answers

Why is this WebRequest code slow?

I requested 100 pages that all 404. I wrote { var s = DateTime.Now; for(int i=0; i < 100;i++) DL.CheckExist("http://google.com/lol" + i.ToString() + ".jpg"); var e = DateTime.Now; var d = e-s; d=d; …
user34537
12
votes
2 answers

C# Xml in Http Post Request Message Body

I am looking for an example of how, in C#, to put a xml document in the message body of a http request and then parse the response. I've read the documentation but I would just like to see an example if there's one available. Does anyone have a…
jumbojs
  • 4,768
  • 9
  • 38
  • 50
12
votes
2 answers

Error (HttpWebRequest): Bytes to be written to the stream exceed the Content-Length bytes size specified

I can't seem to figure out why I keep getting the following error: Bytes to be written to the stream exceed the Content-Length bytes size specified. at the following line: writeStream.Write(bytes, 0, bytes.Length); This is on a Windows Forms…
Vigs
  • 331
  • 2
  • 3
  • 14
12
votes
3 answers

HttpWebResponse with MJPEG and multipart/x-mixed-replace; boundary=--myboundary response content type from security camera not working

I have an ASP.NET application that I need to show a video feed from a security camera. The video feed has a content type of 'multipart/x-mixed-replace; boundary=--myboundary' with the image data between the boundaries. I need assistance with…
arri.io
  • 556
  • 1
  • 5
  • 19
1
2
3
70 71