Guoqi -
Check for HttpWebResponse .StatusCode == HttpStatusCode. OK.
Sample function from MSDN
(
http://msdn.microsoft.com/library/de...scodetopic.asp)
public static void GetPage(String url)
{
try
{
// Creates an HttpWebRequest for the specified URL.
HttpWebRequest httpWebRequest =
(HttpWebRequest )WebRequest.Cre ate(url);
// Sends the HttpWebRequest and waits for a response.
HttpWebResponse httpWebResponse =
(HttpWebRespons e)httpWebReques t.GetResponse() ;
if (httpWebRespons e.StatusCode == HttpStatusCode. OK)
Console.WriteLi ne("\r\nRespons e Status Code is OK and
StatusDescripti on is: {0}",
httpWebResponse .StatusDescript ion);
// Releases the resources of the response.
httpWebResponse .Close();
}
catch(WebExcept ion e)
{
Console.WriteLi ne("\r\nWebExce ption Raised. The following
error occured : {0}",e.Status) ;
}
catch(Exception e)
{
Console.WriteLi ne("\nThe following Exception was raised :
{0}",e.Message) ;
}
}
- Jon
http://weblogs.asp.net/jgalloway
Guoqi Zheng wrote:
How can I validate an URL in real time, connect to that URL directly
and see it response with ok status.
I think it might need to use webclient, or webrequest + webresponse,
but I have not found out how to do it.
Any help?
--
Kind regards
Guoqi Zheng
guoqi AT meetholland dot com
Http://www.meetholland.com