Hello, I have build a function that checks an internet connection (see
below)
Is there a way to do this so the entire CheckConnection.htm page is not
downloaded? I only want to get the "OK" response without getting the
entire file.
public static bool IsConnected()
{
HttpWebRequest webreq;
HttpWebResponse webresp;
string strurl = "http://www.blah.com/blah/CheckConnection.htm";
bool bConnected = false;
try
{
webreq = (HttpWebRequest) WebRequest.Create(strurl);
webresp = (HttpWebResponse) webreq.GetResponse();
if (webresp.StatusCode == HttpStatusCode.OK)
{
bConnected = true;
}
else
{
bConnected = false;
}
return bConnected;
}
catch (Exception e)
{
string msg =(e.Message);
if (msg ==""){}
bConnected = false;
return bConnected;
}
finally
{
webresp = null;
}
}
Chad Z. Hower aka Kudzu - 16 May 2005 07:41 GMT
> Is there a way to do this so the entire CheckConnection.htm page is not
> downloaded? I only want to get the "OK" response without getting the
> entire file.
You can issue a HEAD command instead of a GET.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Blog: http://blogs.atozed.com/kudzu