By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,260 Members | 1,329 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,260 IT Pros & Developers. It's quick & easy.

decoding the posted data with HttpWebRequest

P: n/a
Dear ASP.NET Programmers,

I am saving the contents of a file to the database using HttpWebRequest and
HttpWebResponse classes. I am also posting some data to the requested page.
What I cannot manage to do is to decode and read the data on the requested
page. Below is the code of the request and then the code in the requested
page given. How can I decode the posted data? Thanks in advance.

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.ASCIIEncoding()
Dim postData As String
Dim data() As Byte
Dim s1, s2 As Stream

postData += "fd=" + txtFlightDate.Text
postData += "&"
postData += "fn=" + txtFlightNo.Text
postData += "&"
postData += "fdest=" + txtFlightDest.Text
postData += "&"
postData += "esc=" + rblMedicalEscort.SelectedItem.Value
postData += "&"
postData += "str=" + rblStretcher.SelectedItem.Value
postData += "&"
postData += "notes=" + txtNotes.Text
data = encoding.GetBytes(postData)
myWebReq =
WebRequest.Create("http://burak/database/medicalDocs/F325.aspx")
myWebReq.Method = "POST"
myWebReq.ContentType = "application/x-www-form-urlencoded"
myWebReq.ContentLength = data.Length
s1 = myWebReq.GetRequestStream()
s1.Write(data, 0, data.Length)
s1.Close()
authCookie = Request.Cookies(FormsAuthentication.FormsCookieNam e)
myWebReq.CookieContainer = cc
myWebReq.CookieContainer.Add(New System.Net.Cookie(authCookie.Name,
authCookie.Value,
authCookie.Path, "burak"))
myWebResp = myWebReq.GetResponse
Dim docSize As Integer = myWebResp.ContentLength
Dim docBuffer(docSize) As Byte
s2 = myWebResp.GetResponseStream
s2.Read(docBuffer, 0, docSize)
Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.