Re: Check for internet connection
Stephen Bub <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.winforms |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
If the internet connection is closed, then the following exception is generated from within GetResponse(), before I can check HttpWebResponse.StatusCode: System.Net.WebException: The underlying connection was closed: The remote name could not be resolved. I would like determine if an internet connection is available before calling GetResponse() and potentially generating an exception, e.g. for dial up users. On Mon, 19 Mar 2007 00:58:24 +0200, Stoyan Damov <[email protected]> wrote: >On 3/19/07, Stephen Bub <[email protected]> wrote: >> Which status code? HTTPWebRequest.GetResponse() returns a WebResponse >> which doesn't have a status code. The WebException has a status property, >> but generating a WebException is exactly what I'm trying to avoid. >> > >cast to HttpWebResponse, then get its HttpStatusCode > >Cheers, >Stoyan