HttpWebRequest - operation has been disabled

I am trying to invoke a webpage using HttpWebRequest, however I get "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 this did not seem to do this. What am I doing wrong?

Edit:

When I use the full example: http://support.microsoft.com/kb/307023 , starting / debugging it from Visual C # as a console application, it does not time out. When I install this program to run in the Windows Task Scheduler, it makes a timeout.

+4
source share
2 answers

For such a simple operation, run it using WebClient.

It is much less complex and less likely to be something specific to WebRequest , which is the problem. Also, did you try to run it from the same machine outside of Visual Studio?

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

IIS Express does a special job - IIS Express allows an external request

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

+1
source

Try adding this code:

ServicePointManager.DefaultConnectionLimit = 500;

Parallel connections can cause a timeout error. In my case, this works great.

0
source

Source: https://habr.com/ru/post/1437060/


All Articles