Vb.net 如何从失败的webclient.downloadstring获取结果?

Vb.net 如何从失败的webclient.downloadstring获取结果?,vb.net,Vb.net,如果我们在服务器上使用webclient.downloadstring时出错,我们将一无所获 Try result = webClient.DownloadString("https://api.bodis.com/domainclassification?domain=" + CurrentBlog.Domain) Catch ex As Exception System.Windows.Forms.Applica

如果我们在服务器上使用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是有问题的,因为它混合了安全和非安全的东西。但是,它在InternetExplorer中仍然提供输出。我想使用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

试试,怎么试试?我应该如何修改该代码?>将Exception更改为WebException,并查看new
ex
是否包含帮助您识别案例中错误的属性。我不需要知道错误。我想知道你要找的服务器响应?