Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
fake web url identification in the web browser desktop application
Posted
Updated 18-Apr-13 21:13pm
v2

Hi,

try like below.
C#
if (url != "")
{
    UriBuilder uriBuilder = new UriBuilder(url);
    HttpWebRequest request = HttpWebRequest.Create(uriBuilder.Uri);
    HttpWebResponse response = request.GetResponse();
    if (response.StatusCode == StatusCode.NotFound)
    {
        // URL Not Found
    }
    if (response.StatusCode == StatusCode.OK)
    {
        // Valid URL
    }        
}


hope it helps.
 
Share this answer
 
if (url != "")
{
UriBuilder uriBuilder = new UriBuilder(url);
HttpWebRequest request = HttpWebRequest.Create(uriBuilder.Uri);
HttpWebResponse response = request.GetResponse();
if (response.StatusCode == StatusCode.NotFound)
{
// URL Not Found
}
if (response.StatusCode == StatusCode.OK)
{
// Valid URL
}
}
code error in windows form application
 
Share this answer
 
Comments
[no name] 19-Apr-13 8:22am    
Why would you copy and paste the code from solution 1 to another solution?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900