I've got a problem with my VB.Net-application. When i'm trying to send a request to http://ask.fm without proxy, i got the following response in fiddler: HTTP/1.1 502 Fiddler - DNS Lookup Failed
What does this mean? And why is there no error when using a proxy server for the request?
I send the request with the following code:
Public Function GetRequest(ByVal url As String, ByVal referer As String, ByVal cookie As CookieContainer, Optional proxy As String = "") As String
Dim request As HttpWebRequest
Dim response As HttpWebResponse
Try
Dim cookies As String = ""
request = CType(HttpWebRequest.Create(url), HttpWebRequest)
request.CookieContainer = cookie
request.ServicePoint.Expect100Continue = False
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0"
If referer <> "" Then
request.Referer = referer
End If
request.Timeout = 10000
If proxy <> "" Then
request.Proxy = New WebProxy(proxy)
End If
response = CType(request.GetResponse(), HttpWebResponse)
cookies = response.GetResponseHeader("Set-Cookie")
If url.Contains("ask.fm/") Then
If New Regex("l=.*?; domain=ask.fm; path=/;").Match(cookies).Value = "" Then
Return "ERROR"
End If
End If
Dim source As String = New StreamReader(response.GetResponseStream()).ReadToEnd()
If source.Contains("No robots allowed!") Then
source = "ERROR"
End If
If source = "" Then
source = "ERROR"
End If
Return source
Catch ex As Exception
Return "ERROR"
End Try
End Function
Are you using Fiddler to inspect the traffic? If so, make sure Fiddler can redirect your traffic correctly.
Go to Help > About Fiddler and make sure your Gateway is correct (either set to the proxy you use for accessing internet or equal to No Gateway if you can access directly).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.