C# 检查移动(.m)网站是否存在查询问题

C# 检查移动(.m)网站是否存在查询问题,c#,web,httpwebrequest,exists,C#,Web,Httpwebrequest,Exists,我在检查url是否存在时遇到问题。 我在大多数检查中都使用下面的方法——这是我找到的最好的方法,可以在完整的web请求中保存,但确实如此;nt允许检查地址,例如: m、 英国广播公司 m.的任何移动站点都没有影响和中断 public static bool Does_URL_Exists(string str_url) { // using MyClient from linked post using (var client = new MyClient

我在检查url是否存在时遇到问题。 我在大多数检查中都使用下面的方法——这是我找到的最好的方法,可以在完整的web请求中保存,但确实如此;nt允许检查地址,例如:

m、 英国广播公司

m.的任何移动站点都没有影响和中断

public static bool Does_URL_Exists(string str_url)
    {
        // using MyClient from linked post
        using (var client = new MyClient())
        {
            client.HeadOnly = true;
            // fine, no content downloaded
            try
            {
                //System.Windows.Forms.MessageBox.Show(str_url);
                string s1 = client.DownloadString(str_url);
                return true;
            }
            catch
            {
                return false;
            }

        }

    }
class MyClient : WebClient
{
    public bool HeadOnly { get; set; }
    protected override WebRequest GetWebRequest(Uri address)
    {
        WebRequest req = base.GetWebRequest(address);
        if (HeadOnly && req.Method == "GET")
        {
            req.Method = "HEAD";
        }
        return req;
    }
}

任何关于我是如何做到这一点的线索。www.bbc.co.uk/m也不行。

您不需要将所有链接字符串加载到客户端,只需在“连接到url”正常时检查状态(200)

url为:“”。我认为像手机一样的直接链接是:“

希望能对你有所帮助