How to check if a URL is valid/working (host is reachable) 
Author Message
 How to check if a URL is valid/working (host is reachable)

As subject says, I'd need to know how to verify that an URL is valid. That
means that not only the syntax is correct, but that the server is reachable.

Any idea how to check that without starting a full download? Pinging is not
possible because it must also work behind http firewall / proxy. Is there
maybe any way having HttpWebrequest opening a connection and then
immediately closing it after successful connect to server?

Thanks!
Felix Haas



Thu, 07 Oct 2004 07:39:35 GMT  
 How to check if a URL is valid/working (host is reachable)
Felix,

    Unfortunately, no, there isn't.  However, you can get around this by
creating an instance of the Socket class and trying to establish a
connection yourself.  Use the Uri class to parse apart your url, getting the
hostname and the port to get requests on (if it is not in the Uri, use the
port appropriate to the protocol, in your case, port 80).  You can then pass
that information to the socket class and test the connection yourself.

    Hope this helps.

--
                    - Nicholas Paldino [.NET/C# MVP]


Quote:
> As subject says, I'd need to know how to verify that an URL is valid. That
> means that not only the syntax is correct, but that the server is
reachable.

> Any idea how to check that without starting a full download? Pinging is
not
> possible because it must also work behind http firewall / proxy. Is there
> maybe any way having HttpWebrequest opening a connection and then
> immediately closing it after successful connect to server?

> Thanks!
> Felix Haas



Fri, 08 Oct 2004 00:21:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. I am new to programming and am lost

2. Checking Who Am I?

3. Am I working on the right lines... (long)

4. ifstream won't work or am i dumb

5. Regular expressions for getting valid URL

6. how good am I? Am I Good Enough????

7. Determine where I am running

8. System.Threading.Timer , am I doing this correctly ?

9. Am i connected?

10. Request - Opinions on Book I am considering:

11. I am puzzled: __nogc new = LNK2001

12. Am I in the wrong NG???

 

 
Powered by phpBB® Forum Software