4

I'm trying to invoke a web page, by using HttpWebRequest, however I'm getting "the operation has timed out error".

string sURL = "http://localhost:53667/MyPage.aspx";

WebRequest wrGETURL = WebRequest.Create(sURL);
wrGETURL.Timeout = 5000;
System.Net.ServicePointManager.DefaultConnectionLimit = 5000;

var r = wrGETURL.GetResponse();
r.Close();
wrGETURL.Abort();

As you can see I added the DefaultConnectionLimit property, closed the response as other threads suggested, but that didn't seem to do it. What am I doing wrong?

Edit:

When I use the full example from: http://support.microsoft.com/kb/307023, running/debugging it from Visual C# as a console app, it doesn't time out. When I set this program to run on Windows Task Scheduler, it does time out.

Rivka
  • 2,172
  • 10
  • 45
  • 74

2 Answers2

1

For such a simple operation give it a run with WebClient instead.

It's much less complex and has less chance of it being something specific to WebRequest that is the problem. Also have you tried running it from the same machine outside of Visual Studio?

Is the site being hosted by cassini, iis express, iis 6, iis 7, etc ? There are special settings for some of those to allow remote connections, and iirc some may not allow remote connections at all.

IIS Express takes special work - IIS Express enable external request

Cassini can't do it at all per - https://serverfault.com/questions/82899/can-i-access-cassini-from-a-remote-machine

Community
  • 1
  • 1
Maslow
  • 18,464
  • 20
  • 106
  • 193
0

Try adding this code :

ServicePointManager.DefaultConnectionLimit = 500;

Concurrent connections may cause Time out error. In my case, this works fine.