problem with the encodüng of the posted data

  • Thread starter Thread starter buran
  • Start date Start date
B

buran

Hi,

I am posting some data in Turkish with the HttpWebRequest and saving the
response stream in the database. The characters in the page are shown
properly but the Turkish characters in the posted data are not shown
properly. I couldn't find any solution. Please help me...
Code is given below:

Sub UploadDoc()
Dim myWebReq As HttpWebRequest
Dim myWebResp As HttpWebResponse
Dim authCookie As HttpCookie
Dim cc As New CookieContainer()
Dim encoding As New System.Text.UnicodeEncoding()
Dim postData As String
Dim data() As Byte
Dim s As Stream
Dim sr As StreamReader
myWebReq =
WebRequest.Create("http://burak/database/medicalDocs/F324.aspx")
authCookie = Request.Cookies(FormsAuthentication.FormsCookieName)
myWebReq.CookieContainer = cc
myWebReq.CookieContainer.Add(New System.Net.Cookie(authCookie.Name,
authCookie.Value, authCookie.Path, "burak"))
postData += "fd=" + txtFlightDate.Text
postData += "&"
postData += "fn=" + txtFlightNo.Text
postData += "&"
postData += "notes=" + txtNotes.Text
data = encoding.GetBytes(postData)
myWebReq.Method = "POST"
myWebReq.ContentType = "application/x-www-form-urlencoded"
myWebReq.ContentLength = data.Length
s = myWebReq.GetRequestStream()
s.Write(data, 0, data.Length)
myWebResp = myWebReq.GetResponse
s.Close()
sr = New StreamReader(myWebResp.GetResponseStream, encoding.Unicode)
Dim strHTML As String
strHTML = sr.ReadToEnd()
Dim docBuffer() As Byte
docBuffer = encoding.GetBytes(strHTML)
'Upload into the database..

strSql = "spUploadDocIntoDatabase"
 
I have same problem with cyrilic characters (I got spaces). After I deleted
codePage="1251" from aspx file all work correct.
 
Back
Top