Jump to content
Xtreme .Net Talk

how to decode the data posted with HttpWebRequest


Recommended Posts

Posted

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)

.

.

.

End Sub

 

 

and on the other page:

 

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

lblFlightDate.Text = Request("fd")

lblFlightNo.Text = Request("fn")

lblFlightDest.Text = Request("fdest")

lblMedicalEscort.Text = Request("esc")

lblStretcher.Text = Request("str")

lblNotes.Text = Request("notes")

End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...