Can anyone advise what the best way to check (using .NET 3.5) if a remote server is available?
I was thinking of using the following code but would like to know if
If you just want to see whether a given server is online, then a simple ping should do the job in most cases.
PingReply pingReply;
using (var ping = new Ping())
pingReply = ping.Send("http://www.stackoverflow.com/");
var available = pingReply.Status == IPStatus.Success;
Using this method you're not abusing the HTTP server in any way, too.
Otherwise (if you want to check whether a connection is possible on a specific port), that basically looks fine.