Reading post data

dashley

Well-known member
Joined
May 27, 2005
Messages
59
Location
Tennessee
Programming Experience
10+
Hi. I'm using the procedure below (bottom) to post data to a webpage (sent from a desktop application). Once the data reaches the webpage what can i do to
read it and parse it out. It dosnt seem to be in a request.querystring or form.
I've also tried the following but no luck

VB.NET:
Dim sr1 As StreamReader = New StreamReader(Page.Request.InputStream)
        Dim xmldata As String = sr1.ReadToEnd
        Response.Write(xmldata
)

VB.NET:
Public Shared Sub UploadString(ByVal address As String)

        Dim data As String = "my string to pass"
        Dim client As WebClient = New WebClient()
               client.Encoding = System.Text.Encoding.UTF8
       Dim reply As String = client.UploadString(address, "POST", data)
          MsgBox(reply)
    End Sub
 
if you are doing a POST you won't get it in the query string. You can only retrieve values from the query string if it was part of the url you are posting to.

POST data normally is in the form of named value pair unless you get the whole thing and parse it out yourself. Not sure if that the route you are heading on.
 
giadich,

Hi

The reason Im doing this is my data is to long for a querystring. I'm wanting to parse it out myself but don't knwo what route to take.
 
You should find it in Request.InputStream which is the body content of the request. Try this:
VB.NET:
Dim sr As New IO.StreamReader(Request.InputStream, Request.ContentEncoding)
Dim input As String = sr.ReadToEnd
sr.Close()
I know it is similar to what you tried except the encoding, but that's where it should be. (and is when I run it)
(it's only headers that are name/value pairs)
 
Back
Top