error: (406) Not Acceptable

itay

New member
Joined
Jun 6, 2007
Messages
4
Programming Experience
Beginner
hello,

i'm trying to read content from live.com with httprequest, and i get this error: "The remote server returned an error: (406) Not Acceptable."

my code is working fine for another page on another site.

any idea? thanks...

code:
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://search.live.com/cashback/products/offerings/18003/15274557?p=1"), HttpWebRequest)
' Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
Console.WriteLine(ControlChars.Cr + "The HttpHeaders are " + ControlChars.Cr + ControlChars.Cr + ControlChars.Tab + "Name" + ControlChars.Tab + ControlChars.Tab + "Value" + ControlChars.Cr + "{0}", myHttpWebRequest.Headers)

' Print the HTML contents of the page to the console.
Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()
Dim streamRead As New StreamReader(streamResponse)
Dim readBuff(256) As [Char]
Dim count As Integer = streamRead.Read(readBuff, 0, 256)
Console.WriteLine(ControlChars.Cr + "The HTML contents of page the are : " + ControlChars.Cr + ControlChars.Cr + " ")
While count > 0
Dim outputData As New [String](readBuff, 0, count)
Console.Write(outputData)
count = streamRead.Read(readBuff, 0, 256)
End While
' Close the Stream object.
streamResponse.Close()
streamRead.Close()
' Release the HttpWebResponse Resource.
myHttpWebResponse.Close()
 
Back
Top