2013-03-05 94 views
4

当我要添加一些网站时:http://www.nirmauni.ac.in/那么它说上面提到的错误,所以如何解决这些问题 我已经给我的代码只是通过和在哪里应该做出改变如何解决这个问题:URI前缀不被识别

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; 
    } 
} 
+0

请提供最低限度的摄制开始。避免从以前的问题/源代码复制粘贴代码。 – 2013-03-05 07:19:53

+0

@Alexei LevenKov兄弟我已经编辑了代码,在这里servicepont .....不工作 – hitarth 2013-03-05 07:22:14

+0

您的编辑仍然不会提供repro,因为您可以从您的意见中看到Sachin的(+1)答案 - 真的只有一行会是足够使用所有样本中的内联。 – 2013-03-05 07:41:47

回答

8

从你的错误看来你是用错误的URL创建一个web请求。

请确保在(HttpWebRequest)HttpWebRequest.Create(url); URL字符串必须与像(HTTP,HTTPS等)适当的协议

+0

@hitarth可以给我你检查非工作示例的任何textBox值。 – Sachin 2013-03-05 07:28:35

+0

“http://nirmauni.ac.in/” – hitarth 2013-03-05 07:29:55

+0

@hitarth nirmauni.ac.in支持哪种协议?你需要添加相应的协议。像这样http://www.nirmauni.ac.in(在http协议的情况下)。你的url参数最终必须有一些协议来创建有效的请求。 – Sachin 2013-03-05 07:36:27