-4
        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 = DirectCast(webRequest.GetResponse(), HttpWebResponse)
        Dim responseStream = response.GetResponseStream
        Dim responseString = responseStream.readAll? 'MethodAccessException doesn't exist


        Dim responseString = responseStream.readAll? 'MethodAccessException doesn't exist

我应该如何更换 Dim responseString = responseStream.readAll

实际的命令是什么?

4

1 回答 1

1

You could pass the response stream to a StreamReader instance and then use the ReadToEnd method:

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)
Using Dim response = DirectCast(webRequest.GetResponse(), HttpWebResponse)
    Using Dim responseStream = response.GetResponseStream
        Using Dim responseReader = new StreamReader(responseStream)
            Dim responseString = responseReader.ReadToEnd()
        End Using
    End Using
End Using

But why bother with an HttpWebRequest when you could use a WebClient directly:

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 responseString = webClient.DownloadString(url)
于 2013-02-24T14:16:11.043 回答