Starr Duskk
asked on
objWebClient.DownloadData - The remote server returned an error: (400) Bad Request.
There are two production servers. It works on one and not the other. So I'm thinking one must have a different setting.
I am using this to scrape a screen, and it works fine locally and on my development site, but on my production site it errors with the message:
The remote server returned an error: (400) Bad Request.
Is there some setting in IIS6 that blocks use of this type of method?
I need to receive the file as a string so that I can edit the relative paths to the style sheets so they can be opened from an email attachment.
I tried this method, but it doesn't give me a string to manipulate. I haven't yet tested it on the production website, so it may not work either.
Any ideas how to receive the above string value before writing?
Dim objWebClient As New WebClient()
Dim objUTF8 As New UTF8Encoding()
Dim strOutput As String = objUTF8.GetString(objWebClient.DownloadData(strUrl))
I am using this to scrape a screen, and it works fine locally and on my development site, but on my production site it errors with the message:
The remote server returned an error: (400) Bad Request.
Is there some setting in IIS6 that blocks use of this type of method?
I need to receive the file as a string so that I can edit the relative paths to the style sheets so they can be opened from an email attachment.
I tried this method, but it doesn't give me a string to manipulate. I haven't yet tested it on the production website, so it may not work either.
Dim myHttpWebRequest As System.Net.HttpWebRequest = CType(System.Net.WebRequest.Create(strUrl), System.Net.HttpWebRequest)
Dim myHttpWebResponse As System.Net.HttpWebResponse = CType(myHttpWebRequest.GetResponse(), System.Net.HttpWebResponse)
Dim receiveStream As Stream = myHttpWebResponse.GetResponseStream()
Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
Dim readStream As New StreamReader(receiveStream, encode)
Dim fs As New FileStream(UniquefileName, FileMode.Create)
Dim BWriter As New BinaryWriter(fs, Encoding.GetEncoding("UTF-8"))
BWriter.Write(readStream.ReadToEnd())
readStream.Close()
BWriter.Close()
fs.Close()
myHttpWebResponse.Close()
Any ideas how to receive the above string value before writing?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.