decoding the posted data with HttpWebRequest

B

buran

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.FormsCookieName)
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top