Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to solve this :The URI prefix is not recognized

When I am going to add some website like http://www.nirmauni.ac.in/, then it says the above mentioned error. So, how to fix this problem? I have given my code. Just go through and say where the change should be made.

bool IsLinkWorking(string url)
{
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);

    //You can set some parameters in the "request" object...
    request.AllowAutoRedirect = true;
    ServicePointManager.ServerCertificateValidationCallback = (s, cert, chain, ssl) => true;

    try
    {
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        return true;
    }
    catch
    { 
        //TODO: Check for the right exception here
        return false;
    }
}
like image 937
hitarth Avatar asked Mar 05 '13 07:03

hitarth


1 Answers

From Your Error It seems that you are creating a web request with wrong url.

Please make sure that in (HttpWebRequest)HttpWebRequest.Create(url); url string must start with proper protocol like (http,https etc.)

like image 53
Sachin Avatar answered Nov 05 '22 16:11

Sachin