473,778 Members | 1,953 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 2730
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
7588
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
3019
by: Shimon Sim | last post by:
I have a custom composite control I have following property
5
3596
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
5569
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
2557
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
1945
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
1607
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
6522
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
2845
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
4127
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
9629
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
9465
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10127
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...
1
10068
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8954
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5370
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...
1
4031
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2863
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.