httpwebrequest

Performance comparison TcpClient vs HttpWebRequest

I'm posting an XML string to a port on an AIX box. I have two ways in which I'm connecting to this box (TcpClient & HttpWebRequest). I have timers in place to give me an idea how long it is taking the AIX box to process my request and respond. It appears that the TcpClient is faster than the HttpWebRequest by up to 100 milliseconds. I s...

Async HttpWebRequest - thread number

Let's say I have the following code : ThreadPool.SetMinThreads(100, 100); for (int i = 0; i < 100; i++) { var request = WebRequest.Create(url); request.BeginGetResponse(ar => { //inside AsynchCallBack method for request.BeginGetResponse() var response = (HttpWebResponse)request.EndGetResponse(ar); string html; using (var ...

Get HTTP requests and responses made using HttpWebRequest/HttpWebResponse to show in Fiddler

Is there any way I can hook Fiddler up to capture requests and responses made using .NET HttpWebRequest and HttpWebResponse? ...

Detect HTTP Proxy error for WebRequest

How to detect that a WebRequest failed due to a web proxy error and not a target web server error? try { var request = (HttpWebRequest)WebRequest.Create("http://www.example.com"); request.Proxy = new WebProxy("localhost"); var response = request.GetResponse(); return response.GetResponseStream(); } catch(WebException we...

C# WebClient - View source question

Hello, I'm using a C# WebClient to post login details to a page and read the all the results. The page I am trying to load includes flash (which, in the browser, translates into HTML). I'm guessing it's flash to avoid being picked up by search engines??? The flash I am interested in is just text (not an image/video) etc and when I "V...

Multi-threaded WebRequest calls and contention

I'm running a C# Console Application that is multi-threaded. The core process retrieves some data to work on, splits it up into a configurable number of smaller datasets, and then spawns the same number of threads to process each subset of data. To process an individual record, a thread has to make a call to a web service using the WebR...

How many concurrent outbound HttpWebRequest calls can be made in ASP.NET / IIS7?

I'm writing an ASP.NET web application which will run on Windows Server 2008 (IIS7). Each page's codebehind will need to make at least one synchronous web service call to an external server using HttpWebRequest and GET. My question - is there any limit to the number of outbound HttpWebRequest calls I can make? (assume that the server I...

C# code for downloading item, that checks text/binary, and gzip/non-compressed???

Hi, QUESTION: Anyone have some code they could post that will download a file from a URL/Link that will automatically handle: (a) binary or text based (b) gzip encoded BACKGROUND: I've been starting to do this but hitting hurdles. Like I was using WebClient however it seems it can't handle the gzip bit (need to drop back to HTTPWebR...

How to generate download file name?

I'm creating asp.net special file manager. all file information saved to SQL Server table. My table is here Table tFile( FileID uniqueidentifier, FileName nvarchar(50), Extension nvarchar(50)) Upload process is: First i'm insert table row and then upload file to server. Then file renamed to FileID (GUID value). For example : 4a6327c4-...

WebRequest.Create throws "Value cannot be null. Parameter name: str" exception

Hi I wrote a wrapper around HttpWebRequest with the constructor : public MyHttpRequest(string requestUrl) { this.webRequest = (HttpWebRequest)WebRequest.Create(requestUrl); } when I pass a vaild url that works in IE : http://www.google.co.il/search?q=%D7%A9%D7%9E%D7%A8+%D7%97%D7%A1%D7%95%D7%9F&amp;ie=utf-8&am...

Adjusting HttpWebRequest Connection Timeout in C#

I believe after lengthy research and searching, I have discovered that what I want to do is probably better served by setting up an asynchronous connection and terminating it after the desired timeout... But I will go ahead and ask anyway! Quick snippet of code: HttpWebRequest webReq = (HttpWebRequest)HttpWebRequest.Create(url); webReq...

Can I do a file upload to a web API using a web file as the source using streaming?

Hi, In C# rather than having to dowloading a file from the web using httpwebrequest, save this to file somewhere, and then upload to a webservice using a POST with the file as one of the parameters... Can I instead somehow open a reader stream from httpwebresponse and then stream this into the http POST? Any code someone could post t...

Techniques to avoid DeadlineExceededException in GAE/J?

I am developing an Twitter4J web application in Google App Engine/Java. I need to show two lists. One is Twitter friends and other is followers. With photo and screen name. It is working fine for people who have 20-30 followers and friends. But it gave me DeadlineExceededException when I try a user who has 150+ followers and friends....

saving page source using web browser vs HttpWebRequest class from C#

Hello, It happens that when I save a web-page source from IE it differs from source downloaded by HttpWebRequest in my C# app. I have saved both files for reference. The one saved from IE is here and the one from HttpWebRequest is here. They differ in formating and in the content itself. It seems that the one downloaded by HttpWebRequ...

Are there any disadvantages of building a .NET REST client using HttpWebRequest/Response

Hi, I want to build a .NET REST client using C#, and although i read lots of posts here about the common practices regarding REST, i could not make sure about something. I've read lots of REST client examples and most of them were using just HttpWebRequest/Response classes to make the requests and receive the responses. What i want to a...

Debugging IIS 404

I have serveral ASP.NET web sites running on a web server with IIS. All sites work fine when accessed with browser. Recently I wrote a simple .NET application that tests the availability of the sites, via making simple HttpRequests. This application return 404 error for some of the sites, even though sites can be accessed via browser. F...

how to read the content of a website?

Hi, i want to read the content of a website and store it in a file by using c# and asp.net. I know we can read it by using httpwebrequest. But is it possible to read the all available links data also? Ex: suppose i want to read http://www.msn.com i can directly give the url and can read the home page data that is no issue. But here that...

How can I write an XML on my hard drive to GetRequestStream

I need to post raw xml to a site and read the response. With the following code I keep getting an "Unknown File Format" error and I'm not sure why. XmlDocument sampleRequest = new XmlDocument(); sampleRequest.Load(@"C:\SampleRequest.xml"); byte[] bytes = Encoding.UTF8.GetBytes(sampleRequest.ToString(...

HttpWebResponse: closing the stream

I'm getting the response from an HttpWebRequest (using a modified version Jeff Richter's CCR wrappers), then inspecting a few of the headers in order to decide whether or not to continue the download. Sometimes I might not want to continue, so I consequently issue response.Close and request.Abort. Is it necessary to issue GetResponseStre...

Perform an action and redirecting to the same URL doesn't refresh the page

We are working on a new web site using Apache, Python and Django. In the development phase, no problem but once binding to Apache, using Firefox 3.5.3, we got a strange problem. We stand on : http://website.fr/search/ When we want to change the ordering of the research, we are sending the user to : http://website.fr/search/order/pri...