473,847 Members | 2,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

I am using webclient to retrieve data from a web site. How do I control the
time-out
of this request?
Nov 22 '05 #1
8 2739
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?

Nov 22 '05 #2

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

Nov 22 '05 #3
Hi,

Here is a sample code:

HttpWebRequest request = (HttpWebRequest )WebRequest.Cre ate(Endpoint);
//Endpoint is the URL to which u are making the request.
request.Method = "POST";
request.Credent ials = CredentialCache .DefaultCredent ials;
request.Content Type = "text/xml"; //depending on the data u are sending this
will change.
request.Timeout =<value in milliseconds>;

---
Bharat Biyani (bs*@orcim.com)
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?

Nov 22 '05 #4
Thank you very much for the reply. Could you give me coding sample on getting
the response. I have difficulty in getting the response.
Nov 22 '05 #5
Hi,

Here is how u get the response.

try
{
// send the request and get the response
response = (HttpWebRespons e)request.GetRe sponse();
}
catch (WebException e)
{
// handle exception
}
Stream responseStream = response.GetRes ponseStream();
StreamReader streamReader = new StreamReader(re sponseStream, Encoding.UTF8);
string responseText = streamReader.Re adToEnd();
response.Close( );

---
Bharat Biyani (bs*@orcim.com)
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.

Nov 22 '05 #6
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.masterli nk.com.tw/futures/QueryOrder.jsp? queryDate=20040 811&actno=11111 111&pwd=1234567 890&idnoR111111 11s&isPreorder= NO"

I pass the urlString to webclient

myWebClient->UploadData(uri String, postArray);

I get the response back without any problem.

Now I pass the same string to HttpWebrequest

HttpWebRequest *request =
dynamic_cast<Ht tpWebRequest*> (WebRequest::Cr eate(uriString) );

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

What is wrong here?

Nov 22 '05 #7
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 (bs*@orcim.com)
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.masterli nk.com.tw/futures/QueryOrder.jsp? queryDate=20040 811&actno=11111 111&pwd=1234567 890&idnoR111111 11s&isPreorder= NO"

I pass the urlString to webclient

myWebClient->UploadData(uri String, postArray);

I get the response back without any problem.

Now I pass the same string to HttpWebrequest

HttpWebRequest *request =
dynamic_cast<Ht tpWebRequest*> (WebRequest::Cr eate(uriString) );

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

What is wrong here?

Nov 22 '05 #8
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.WebE xception.

Nov 22 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7595
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
7
3025
by: Shimon Sim | last post by:
I have a custom composite control I have following property
5
3601
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact that for server control component , code is running on the server side. But if I take as example a Label. I place on a webform an HTM label control and a WebForm label control, I could see that properties are different for
0
5570
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control is used to view the state of the running jobs and schedule new jobs. The control also runs in the context of Internet Explorer (we do this so the administrators of the jobs can always receive the latest control). The property grid is used to...
3
2559
by: _DS | last post by:
Problem with mapping a directory tree to a tree control: It takes a while to recurse subdirs and map them to nodes. This is solved in some books I've seen (MacDonald, Albahari) by reading the subdir only when its node on the tree control is opened. Has anyone pre-packaged this functionality into a control?
5
1949
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project that build a class library dll. Here we have a class called C We have one dependency and that is from the user control to the class library because in the constructor for class B in the user control we have a call to
0
1614
by: pabloazorin | last post by:
I developed a Date Picker web control using C# and .net framework 1.1 I added my control to Visual Studio 2003 IDE toolbar. When I drag and drop my control to design web page, the control renders correctly. If I change to HTML the generated html is <cc1:IT24DateTime id="IT24DateTime1" runat="server" Type="Date"></cc1:IT24DateTime> .... and that works correctly.
15
6544
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
0
2848
by: fredloh | last post by:
i have a tab control on my form. i then have several microsoft date and time picker control on the tab control. when i select a date on any of the date and time picker control, the result of the control's value is always 12:00:00 am instead of the date i selected even though the date displays correctly on the date and time picker control. the controls are unbound. why is this? i also have another identical form where the date and...
5
4141
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like to wrap the control in the proper control type - which is also a container. At design time I want to be able to turn this : <my:container> <asp:textbox />
0
9879
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10981
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10643
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7879
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7050
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5716
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5907
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3158
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.