Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Setting timeout property for System.Net.WebClient Class

By , 20 Jun 2011
Rate this:
Please Sign up or sign in to vote.

You can also use the System.Net.HttpWebRequest implementation of System.Net.WebRequest. It comes packaged with a timeout property -

It would be a simple call to the object:

using System.Net;
HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(new Uri(""));
webRequest.Timeout = 10000; // setting timeout value to 10 secs

HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
// you may now use a stream reader to read the response stream



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Database Developer APN
New Zealand New Zealand
I am a database administrator for APN Holdings Ltd (NZ)

Comments and Discussions

GeneralWould this suffice? Pinmembernerdpro19-Jun-11 17:01 
GeneralI'm going to approve this, but a code snippet would be nice. PinsubeditorIndivara19-Jun-11 15:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 20 Jun 2011
Article Copyright 2011 by nerdpro
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid