Questions tagged [webresponse]

135 questions
36
votes
6 answers

Mocking WebResponse's from a WebRequest

I have finally started messing around with creating some apps that work with RESTful web interfaces, however, I am concerned that I am hammering their servers every time I hit F5 to run a series of tests.. Basically, I need to get a series of web…
Rob Cooper
  • 28,567
  • 26
  • 103
  • 142
22
votes
6 answers

How to properly dispose of a WebResponse instance?

Normally, one writes code something like this to download some data using a WebRequest. using(WebResponse resp = request.GetResponse()) // WebRequest request... using(Stream str = resp.GetResponseStream()) ; // do something with the…
Marcus
  • 5,987
  • 3
  • 27
  • 40
18
votes
4 answers

Reading data from an open HTTP stream

I am trying to use the .NET WebRequest/WebResponse classes to access the Twitter streaming API here "http://stream.twitter.com/spritzer.json". I need to be able to open the connection and read data incrementally from the open connection. Currently,…
user108687
  • 369
  • 1
  • 2
  • 8
10
votes
1 answer

WebRequest.GetResponse locks up?

When writing the below my code locks up on GetResponse. Why? try { WebRequest myWebRequest = WebRequest.Create(strURL); WebResponse myWebResponse = myWebRequest.GetResponse(); //more code here
user34537
9
votes
3 answers

WinRT StorageFile write downloaded file

I'm struggling with a easy problem. I want to download an image from web using this code: WebRequest requestPic = WebRequest.Create(@"http://something.com/" + id + ".jpg"); WebResponse responsePic = await requestPic.GetResponseAsync(); Now I wanted…
Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
7
votes
2 answers

How can I avoid a "Bad Request - Invalid Hostname" error when making a REST call from a Compact Framework client?

I used this code from here to try to call a REST Controller method on a Web API server app from a Compact Framework client: public static void SendXMLFile3(string uri, string data) { WebRequest request = WebRequest.Create (uri); …
6
votes
2 answers

Why do we need to set the Content-Type header of an HTTP request?

I have the following questions: What is the content type? Why do we need to set the content type header of an HTTP request? How many types of header content can be set? Please provide documentation if possible.
6
votes
2 answers

Why does WebResponse never end when reading twitter firehose stream?

The following function will pull down first X messages from Twitter firehose, but looks like WebResponse blocks and never exits the function: public void GetStatusesFromStream(string username, string password, int nMessageCount) { WebRequest…
martimedia
  • 63
  • 5
5
votes
1 answer

Webview only showing raw HTML text on some pages

I am working on a project where we are interested in intercepting some HTTP traffic from a WebView, then attach some extra headers to the requests and then get a return back and display it in the WebView. For this, we use the…
Simon Langhoff
  • 1,395
  • 3
  • 18
  • 28
5
votes
1 answer

Http Get Request GetResponse Error

Im trying to send a get request and get the content of a webpage. i have these code. string url = "www.google.com"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse response =…
abidinberkay
  • 1,857
  • 4
  • 36
  • 68
4
votes
1 answer

The remote server returned an error: (422)

I am getting following error when I am trying to get WebResponse using WebResponse response = request.GetResponse() The remote server returned an error: (422). at System.Net.HttpWebRequest.GetResponse() at…
Ramesh Soni
  • 15,867
  • 28
  • 93
  • 113
4
votes
1 answer

c# Webrequest Post and GetResponse

I am writing a program that will submit a XML to a website. The code written works fine, but sometimes it just stops working for some reason, throwing a System.Net.ProtocolViolationException. I can close the program and re-run - it starts working…
user2664502
  • 85
  • 2
  • 2
  • 5
3
votes
3 answers

Parallel process a intensive IO function

I have this sample code. List> objects = new List>(); foreach (string url in urls) { objects.add(processUrl(url)) } I need to process the URL, processUrl down load the page and run many regex…
waldecir
  • 376
  • 2
  • 8
  • 21
3
votes
1 answer

How use HttpWebResponse and WebResponse in .NET Core?

I'm porting an old C# Shared Lib to a Standard Library. However I'm facing with a lot of System.Net.HttpWebResponse and System.Net.WebResponse references. It used to exist on .Net Framework 4.5 But I'm not able to find similar in .Net standard. What…
Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
3
votes
1 answer

How to determine the encoding of a webresponse stream?

How to determine the encoding of a webresponse stream ?
Vladimir Georgiev
  • 601
  • 1
  • 10
  • 17
1
2 3
8 9