Deskripsi
i don't know if my article is still working , here's the code of web header for request or response for vb.net
Howto
Get current your web header (request) and send to webserver :
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.msn.com"), HttpWebRequest)
Dim myWebHeaderCollection As WebHeaderCollection = myHttpWebRequest.Headers
myWebHeaderCollection.Add("Accept-Language:da")
myWebHeaderCollection.Add("Accept-Language", "en;q" + ChrW(61) + "0.8")
myHttpWebRequest.Method = "POST"
myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"
'Get the associated response for the above request.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
'Print the headers for the request.
System.Diagnostics.Debug.Write(myWebHeaderCollection)
myHttpWebResponse.Close()
Get current response web header from webserver :
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.detik.com"), HttpWebRequest)
' Sends the HttpWebRequest and waits for a response.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
System.Diagnostics.Debug.Write(ControlChars.Lf + ControlChars.Cr + "The following headers were received in the response")
Dim i As Integer
While i < myHttpWebResponse.Headers.Count
System.Diagnostics.Debug.Write(myHttpWebResponse.Headers.Keys(i) & ":" & myHttpWebResponse.Headers(i) & vbCrLf)
i = i + 1
End While
myHttpWebResponse.Close()
Post a Comment
Harap gunakan bahasa yang baik dan sopan, terima kasih