1

如果我们在出错的服务器上使用 webclient.downloadstring,我们什么也得不到

        Try
            result = webClient.DownloadString("https://api.bodis.com/domainclassification?domain=" + CurrentBlog.Domain)
        Catch ex As Exception
            System.Windows.Forms.Application.DoEvents()
        End Try

通常结果包含响应。但万一出错结果为空。

我想知道一些事情。例如,即使结果不好,通常也会有自定义的 404 消息等。

api.bodis.com 是有问题的,因为它混合了安全和非安全的东西。但是,它无论如何都会在 Internet Explorer 中提供输出。我想使用 webclient,我想知道输出

得到 ex.response 没有任何结果

        Dim adult = webClient.DownloadString("http://googleads.g.doubleclick.net/apps/domainpark/domainpark.cgi?callback=_google_json_callback&output=js&client=ca-dp-godaddy2_xml&domain_name=" + CurrentBlog.Domain)
        'ias.NavigateTillComplete("https://api.bodis.com/domainclassification?domain=" + CurrentBlog.Domain)
        Dim result = ""
        Dim url = "http://api.bodis.com/domainclassification?domain=" + CurrentBlog.Domain
        Dim webRequest = DirectCast(System.Net.HttpWebRequest.Create(url), System.Net.HttpWebRequest)
        Dim response As HttpWebResponse
        Try
            response = DirectCast(webRequest.GetResponse(), HttpWebResponse)
        Catch ex As System.Net.WebException
            System.Windows.Forms.Application.DoEvents()
            response = DirectCast(ex.Response, HttpWebResponse) 'is nothing there
        End Try

        Dim responseStream = response.GetResponseStream
4

0 回答 0