Dear ALL;
You have to check for the Http status code 200 which means it is ok and the link is found and working. Use the following code
if(response.StatusCode == HttpStatusCode.OK)
Thanks a lot for your Time and Collaboration.
Muhammad Makhaly
Senior .Net Developer
Senior .Net Developer
From: Ehab Elaraby <ehab4290@yahoo.com>
To: "Developers_For_Ever@yahoogroups.com" <Developers_For_Ever@yahoogroups.com>
Sent: Wednesday, December 14, 2011 11:02 PM
Subject: Re: [Developers_For_Ever] Question: Check webpage availability...
To: "Developers_For_Ever@yahoogroups.com" <Developers_For_Ever@yahoogroups.com>
Sent: Wednesday, December 14, 2011 11:02 PM
Subject: Re: [Developers_For_Ever] Question: Check webpage availability...
I think you must check the status code for the page URL, here http://en.wikipedia.org/wiki/List_of_HTTP_status_codes you can find status codes and what it means.
From: Marwa Ahmad <marwa.ahmed86@yahoo.com>
To: Egypt Pro <egyptpro@yahoogroups.com>; Group EgyptDotNetDevelopers <EgyptDotNetDevelopers@yahoogroups.com>; Group DevelopersForEver <developers_for_ever@yahoogroups.com>
Sent: Wednesday, December 14, 2011 6:41 PM
Subject: [Developers_For_Ever] Question: Check webpage availability...
To: Egypt Pro <egyptpro@yahoogroups.com>; Group EgyptDotNetDevelopers <EgyptDotNetDevelopers@yahoogroups.com>; Group DevelopersForEver <developers_for_ever@yahoogroups.com>
Sent: Wednesday, December 14, 2011 6:41 PM
Subject: [Developers_For_Ever] Question: Check webpage availability...
Hi,
I have an issue, I want to check if a certain url is valide one or not, so I used:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);//url: is the one I need to check its availability)
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//and then I returned the: response.StatusCode.ToString(), it always return found!!! although the website isn't valide.
For instance, "http://www.google.co.uk" => Found
"http://www.googleeeee.co.uk" => Found !!!!!!!!!!!!!!!!!
Please, I need your opinions.
Thanks in advance.
Marwa Ahmad
__._,_.___
Kindly visit my Blog http://amrsaafan.blogspot.com
MARKETPLACE
.
__,_._,___
0 comments:
Post a Comment