How to set the TIMEOUT property of WebClient class???
-
-
:confused:I use C# to develop a web embed application, and I find that using WebClient is very easy to raise a web request and get the response. But I don' know how to set the TIMEOUT property(or something like that) to prolong the request time.
The System.Net.WebRequest class has a Timeout property, which is a value in milliseconds or System.Threading.Timeout.Infinite. See http://www.dotgnu.org/pnetlib-doc/System/Net/WebRequest.html[^] for more details of the class. Chris Jobson
-
The System.Net.WebRequest class has a Timeout property, which is a value in milliseconds or System.Threading.Timeout.Infinite. See http://www.dotgnu.org/pnetlib-doc/System/Net/WebRequest.html[^] for more details of the class. Chris Jobson
-
You mean I cann't use WebClient anymore(I have to use WebRequest and WebResponse instead)???? Do you know some resolution that can extend the functionality of WebClient and realize the function I need? Tnanks.
Sorry, I thought that WebClient had a way to access the WebRequest that it was using internally - but I was wrong, so maybe you will have to use WebRequest/WebResponse:(. The only other idea I have is that if you know in advance the URLs you will be accessing you could use WebRequest.RegisterPrefix to register a class of your own (for just the URL you want) that implements the IWebRequestCreate interface, and that class could return an instance of one of the standard WebRequest objects (e.g. an HttpWebRequest) with the timeout set to whatever you want. See the web page I referenced in my previous answer for more details. However, I must stress that I haven't tried this, and it's based only on my understanding of the information on the www.dotgnu.org website. Good luck! Chris Jobson