PC Review


Reply
Thread Tools Rate Thread

How to control the time-out of a webclient request?

 
 
=?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?=
Guest
Posts: n/a
 
      5th Aug 2004
I am using webclient to retrieve data from a web site. How do I control the
time-out
of this request?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmhhcmF0IEJpeWFuaQ==?=
Guest
Posts: n/a
 
      5th Aug 2004
Hi,

The WebClient class does not offer any property where u can set the timeout
period. If possible use the HttpWebrequest instead. The Webclient insternally
uses the webrequest class. In HttpWebrequest you can set the request timeout
property.

"Kueishiong Tu" wrote:

> I am using webclient to retrieve data from a web site. How do I control the
> time-out
> of this request?

 
Reply With Quote
 
=?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?=
Guest
Posts: n/a
 
      6th Aug 2004

Thank you for your reply. Could you give me coding sample how to use
httpwebrequest and set the time-out property?



 
Reply With Quote
 
=?Utf-8?B?QmhhcmF0IEJpeWFuaQ==?=
Guest
Posts: n/a
 
      7th Aug 2004
Hi,

Here is a sample code:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Endpoint);
//Endpoint is the URL to which u are making the request.
request.Method = "POST";
request.Credentials = CredentialCache.DefaultCredentials;
request.ContentType = "text/xml"; //depending on the data u are sending this
will change.
request.Timeout=<value in milliseconds>;

---
Bharat Biyani ((E-Mail Removed))
http://www.orcim.com

"Kueishiong Tu" wrote:

>
> Thank you for your reply. Could you give me coding sample how to use
> httpwebrequest and set the time-out property?
>
>
>

 
Reply With Quote
 
=?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?=
Guest
Posts: n/a
 
      8th Aug 2004
Thank you very much for the reply. Could you give me coding sample on getting
the response. I have difficulty in getting the response.


 
Reply With Quote
 
=?Utf-8?B?QmhhcmF0IEJpeWFuaQ==?=
Guest
Posts: n/a
 
      9th Aug 2004
Hi,

Here is how u get the response.

try
{
// send the request and get the response
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException e)
{
// handle exception
}
Stream responseStream = response.GetResponseStream();
StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8);
string responseText = streamReader.ReadToEnd();
response.Close();

---
Bharat Biyani ((E-Mail Removed))
http://www.orcim.com

"Kueishiong Tu" wrote:

> Thank you very much for the reply. Could you give me coding sample on getting
> the response. I have difficulty in getting the response.
>
>

 
Reply With Quote
 
=?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?=
Guest
Posts: n/a
 
      11th Aug 2004
I am still not getting the response. I think the problem has something to do
with
the way of making the request.

I have a uriString which looks like

uriString =
S"http://trade1.masterlink.com.tw/futures/QueryOrder.jsp?queryDate=20040811&actno=11111111&pwd=1234567890&idnoR11111111s&isPreorder=NO"

I pass the urlString to webclient

myWebClient->UploadData(uriString, postArray);

I get the response back without any problem.

Now I pass the same string to HttpWebrequest

HttpWebRequest *request =
dynamic_cast<HttpWebRequest*> (WebRequest::Create(uriString));

However I do not get any reponse and get time-out exception.

What is wrong here?

 
Reply With Quote
 
=?Utf-8?B?QmhhcmF0IEJpeWFuaQ==?=
Guest
Posts: n/a
 
      13th Aug 2004
Hi,

Can u give the complete code...I tried that URL on the browser and the
browser is giving 500 internal error. So it means that prior to this u need
to do some other things also like logging in etc.

---
Bharat Biyani ((E-Mail Removed))
http://www.orcim.com

"Kueishiong Tu" wrote:

> I am still not getting the response. I think the problem has something to do
> with
> the way of making the request.
>
> I have a uriString which looks like
>
> uriString =
> S"http://trade1.masterlink.com.tw/futures/QueryOrder.jsp?queryDate=20040811&actno=11111111&pwd=1234567890&idnoR11111111s&isPreorder=NO"
>
> I pass the urlString to webclient
>
> myWebClient->UploadData(uriString, postArray);
>
> I get the response back without any problem.
>
> Now I pass the same string to HttpWebrequest
>
> HttpWebRequest *request =
> dynamic_cast<HttpWebRequest*> (WebRequest::Create(uriString));
>
> However I do not get any reponse and get time-out exception.
>
> What is wrong here?
>

 
Reply With Quote
 
=?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?=
Guest
Posts: n/a
 
      18th Aug 2004
Try this url

http://trade7.masterlink.com.tw/futures/QuotePrice.jsp

you should be able to run this url on the browser.

The webclient call gets the response. However the httpwebrequest gets
System.Net.WebException.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using webclient to send request to jsp page =?Utf-8?B?S2V2aW4=?= Microsoft ASP .NET 1 14th Oct 2005 05:55 PM
WebClient Request Unable to Connect Localhost Jim Microsoft Dot NET Framework 0 26th Jul 2005 06:07 PM
WebClient request page with authentication kids_pro Microsoft C# .NET 1 6th May 2005 08:39 PM
404 error with WebClient request Tony B Microsoft VB .NET 10 27th Nov 2003 03:56 PM
FEATURE REQUEST: User Control components in design time debugging issue news.microsoft.com Microsoft Dot NET Framework Forms 0 5th Nov 2003 09:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:53 AM.