webrequest

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 responses so I can test I am parsing the varying responses correctly, rather than hit their...

Is WebRequest The Right C# Tool For Interacting With Websites?

I'm writing a small tool in C# which will need to send and receive data to/from a website using POST and json formatting. I've never done anything like this before in C# (or any language really) so I'm struggling to find some useful information to get me started. I've found some information on the WebRequest class in C# (specifically f...

Enforcing a strict timeout policy on a server side webrequest

We will need to call out to a 3rd party to retrieve a value using REST, however if we do not receive a response within 10ms, I want to use a default value and continue processing. I'm leaning towards using an asynchronous WebRequest do to this, but I was wondering if there was a trick to doing it using a synchronous request. Any advice...

Returning form, querystring, cookie values by priority in ASP.NET MVC

I'm wondering why query string is preferred when getting values from user request. Where? 1) Code of System.Web.Mvc.DefaultModelBinder looks like this (only part of it): HttpRequestBase request = controllerContext.HttpContext.Request; if (request != null) { if (request.QueryString != null) { values =...

WebRequest from localhost to localhost : why is it being denied?

...

Best way to test if a website is alive from a C# applicaiton

I am looking for the best way to test if a website is alive from a C# application. Background My application consists of a Winforms UI, a backend WCF service and a website to publish content to the UI and other consumers. To prevent the situation where the UI starts up and fails to work properly because of a missing WCF service or websi...

c# WebRequest class and headers

Hi, When I try to set the header properties on a WebRequest object, I get the following exception This header must be modified using the appropriate property I've tried modifying the .Headers propery and adding them that way like so webRequest.Headers.Add(HttpRequestHeader.Referer, "http://stackoverflow.com"); But still getting exce...

unable to post a https WebRequest in .net?

Hi i am encountering problems trying to post a WebRequest under Https. i received the following errors 1.-The underlying connection was closed: Unable to connect to the remote server. 2.-the operation TimeOut 3-The underlying connection was closed: Could not establish secure channel for SSL/TLS. i tried with about 3 or 4 different ...

C#: Downloading a URL with timeout

What's the best way to do it in .NET? I always forget what I need to Dispose() (or wrap with using). EDIT: after a long time using WebRequest, I found out about customizing WebClient. Much better. ...

c# HttpWebRequest Server Unavailable 503 problem

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: CSharp service that is sending to a https website. HTTPS Website on another place that I cant say. HTTPS Local Website locally that is just...

How to get website title from c#

I'm revisiting som old code of mine and have stumbled upon a method for getting the title of a website based on its url. It's not really what you would call a stable method as it often fails to produce a result and sometimes even produces incorrect results. Also, sometimes it fails to show some of the characters from the title as they ar...

Using WebRequest to save URL as Image thumbnail in VB.NET

I'm trying to write a simple routine where I pass it a URL and it goes and renders the content of the webresponse as a jpg. I found a solution somehwere in C# and ported it to vb.net, however when I run it, it throws an argumentexception "parameter is not valid" when trying to instantiate the image. Can someone take a look at the follo...

Deploy ClickOnce application using HttpWebRequest

Hi, I'm trying to launch my ClickOnce application using C# code with HttpWebRequest class. The application can be deployed fine using IE. But when doing the deployment with my code, it seems only the .application file is downloaded to client. My code is as below. HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create("h...

I need help setting .NET HttpWebRequest timeout

My objective is to get the answer from up to 6000 Urls in the shortest time. It was working very well (12 seconds for 5200 LAN Addresses) until some delay started to happen. My code uses up to 20 simultaneous HttpWebRequest.BeginGetResponse with ThreadPool.RegisterWaitForSingleObject for timeout handling. However some (up to 4 in 5,000...

HttpWebRequests Failing on Subsequent Calls

Hi, I know this is a vague question, especially since I am not providing any code, but I am developing a .Net 2.0 application, and we have a WebRequest which posts data to an internally built API. The strange thing happens on our 3rd (and always the 3rd) subsequent request which fails at the GetRequestStream() method of the request. Th...

Webrequest Disallow AutoRedirect

Hi In .Net 2.0 how can I disallow AutoRedirect when using WebRequest? I found some source code were there where used an AllowAutoRedirect property, but on my WebRequest there is no such property. ...

"too many automatic redirections were attempted" error message when using a httpWebRequest in VB.NET

I am attempting to request a page like "http://www.google.com/?q=random" using the webrequest class in vb.net. we are behind a firewall, so we have to authenticate our requests. I have gotten past the authentication part by adding my credentials. But once that works it seems to go into a redirecting loop. Does anyone have an ideas, comm...

Remote HTTP Post with CSharp

How do you do a Remote HTTP Post (request) in CSharp? i really needs this pls. :( ...

How do I use WebRequest to access an SSL encrypted site using https?

I'm writing a program that reads content from a user provided URL. My problem is in the code that goes something like this: Uri uri = new Uri(url); WebRequest webRequest = WebRequest.Create(uri); WebResponse webResponse = webRequest.GetResponse(); ReadFrom(webResponse.GetResponseStream()); And this is breaking if the provided url is a...

Web Requests in C# for SilverLight 2.0

I have been using the following code to obtain a simple web response from Apache 2.2 in SilverLight to no avail. private void bDoIt_Click(object sender, RoutedEventArgs e) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri("/silverlight/TestPage2.html")); request.Method = "POST"; requ...