473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

WebResponse timeout?

Bob
Hi,
Is there any way of setting a time out for a webresponse.
I managed to cause our inhouse Webserver to not respond to a request.
The requesting code just sat there waiting patiently.
I would like it to be a little bit impatient and give up after n seconds.
Code snippet follows:
Thanks
Bob
HttpWebRequest r = (HttpWebRequest)WebRequest.Create(sURL);

Stream streamResponse;

HttpWebResponse response;

try

{
bool lValidTrans = false;

// Form the request

FormWebRequest(ref r, req);

// Get the response.

response = (HttpWebResponse)r.GetResponse();//Here we wait and wait and
wait...
Aug 22 '06 #1
2 7630
Bob,
Did you miss the Timeout property?

http://msdn2.microsoft.com/en-us/lib...t.timeout.aspx
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Bob" wrote:
Hi,
Is there any way of setting a time out for a webresponse.
I managed to cause our inhouse Webserver to not respond to a request.
The requesting code just sat there waiting patiently.
I would like it to be a little bit impatient and give up after n seconds.
Code snippet follows:
Thanks
Bob
HttpWebRequest r = (HttpWebRequest)WebRequest.Create(sURL);

Stream streamResponse;

HttpWebResponse response;

try

{
bool lValidTrans = false;

// Form the request

FormWebRequest(ref r, req);

// Get the response.

response = (HttpWebResponse)r.GetResponse();//Here we wait and wait and
wait...
Aug 22 '06 #2
Bob
Hi Peter,
Sure did.
Bad hair day.
thanks
Bob

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.comwrote in message
news:7C**********************************@microsof t.com...
Bob,
Did you miss the Timeout property?

http://msdn2.microsoft.com/en-us/lib...t.timeout.aspx
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Bob" wrote:
Hi,
Is there any way of setting a time out for a webresponse.
I managed to cause our inhouse Webserver to not respond to a request.
The requesting code just sat there waiting patiently.
I would like it to be a little bit impatient and give up after n
seconds.
Code snippet follows:
Thanks
Bob
HttpWebRequest r = (HttpWebRequest)WebRequest.Create(sURL);

Stream streamResponse;

HttpWebResponse response;

try

{
bool lValidTrans = false;

// Form the request

FormWebRequest(ref r, req);

// Get the response.

response = (HttpWebResponse)r.GetResponse();//Here we wait and wait and
wait...


Aug 22 '06 #3

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

Similar topics

6
by: Jonathan | last post by:
Calling the System.Net.WebResponse.GetResponse method (see code below) results in the following error: System.Net.WebException: The underlying connection was closed: An unexpected error occurred...
1
by: Peter | last post by:
Hi I am trying to do very simple http client that requires a login, copy cookie snet by a server and does a request with the cookies. WebRequest->CookieContainer/WebResponse->Cookies does not...
2
by: Jonax | last post by:
Hi guys, I have the following code that retrieves a webpage. My problem is getting it to use the right encoding. I've tested it against a danish page, but it won't show the danish characters....
1
by: Rajiv Barik | last post by:
hi , I am trying to download a zip file from a http site using webResponse . here's the code WebRequest wReq ; wReq = WebRequest.Create(wUri ) ; wReq.Credentials = new NetworkCredential...
2
by: Jeff G. | last post by:
Hello everyone, I have read through the newsgroups (thank God for 'em!) extensively looking for an example of how to pass a file (PDF) from a webresponse stream down to a web client. Here's the...
0
by: archana | last post by:
Hi all, I am facing very strange problem while using webrequest. What i am doing is i have one url which i want to validate. so i am using webrequest and webresponse. My code is as below:-...
6
by: nakul.reddy | last post by:
I'm trying to use HTTPWebRequest to POST data to a website using multipart/form-data. It's HTTPS, and it returns a response object with -1 ContentLength. Any help would be appreciated! Below...
4
by: CindyH | last post by:
Hi - hope someone can help with this - this code was working for a while in the 'real' code and then suddenly stopped - not sure what happen. I made two simple forms on localhost to try to test...
0
by: deeps1512 | last post by:
hi All, I have written the following code to get a webresponse. XmlDocument myxmlDoc1 = new XmlDocument(); myxmlDoc1.LoadXml(BkXMLRQ); string s = myxmlDoc1.OuterXml;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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,...

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.