>How/Where do you set the Method property to "HEAD"
>some details please, thank you,
No problem.
Here we go. I wrote a small console application. You will need to add
references to System.Net and System.Web, as well as (System.IO) if you
want to retrieve the actual content
WebRequest r=null;
WebResponse res=null;
try{
r = HttpWebRequest.Create("http://thesiteiwanttocheck.com");
r.Method="HEAD";
res = r.GetResponse();
}
catch(WebException ex){
Console.WriteLine(ex.Status);
}
finally{
if(res!=null)
res.Close();
}
If the site cannot be accessed, a web exception could be thrown. You
can interrogate the status property to discover why. It could be a
problem from your end e.g. proxy authentication, etc or it could be
something wrong with the site. Check the status property before you
flag the site as unavailable!
Unless you say otherwise, the default method used by a HttpWebRequest
is GET. So before we get the response, we set the method as
appropriate.
To prove that the full body is not being retrieved, add the following
code just after GetResponse()
StreamReader sr = new StreamReader(res.GetResponseStream());
Console.Write(sr.ReadToEnd());
Then toggle the Method property between HEAD and GET and see what
happens.
Hope that helps
--
http://bytes.thinkersroom.com
IfThenElse - 19 Oct 2007 15:50 GMT
Rad,
Excellent and Thank YOU so much for the detailed code, Now I know what you
are saying.
It definitely helped me out.
>>How/Where do you set the Method property to "HEAD"
>>some details please, thank you,
[quoted text clipped - 43 lines]
> --
> http://bytes.thinkersroom.com