Why I always get 'The operation has timed-out.' exception from some pages?

A

Andy Chen

Hi all,

Please help me to look at the following code, I always get a 'The operation
has timed-out.' exception. But the URL can be opened in IE properly. I am
wondering if I missed some code. Any help would appreciate!!

HttpWebRequest httpReq;
HttpWebResponse httpResp;
try
{
httpReq =
(HttpWebRequest)WebRequest.Create("http://safety.live.com);
httpReq.Timeout = 10000;
httpReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; .NET CLR 1.0.3705";
httpReq.ContentType = "application/x-www-form-urlencoded";
httpResp = (HttpWebResponse) httpReq.GetResponse();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
}
 
G

Guest

Where is the code running from?

If this is an ASP.NET app the your code will be running under the ASPNET
user on the server and I'm guessing if you are in an office your firewall is
blocking the connection?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top