POSTing woes...

S

Stacey Levine

Please tell me if this makes sense.

I have written an ASPX page to handle and process POSTed XML data to it. I
am expected the data to be in the Request.Form object. This works perfectly
fine when data is posted from an HTML page and even from a HTTPWebrequest..
Now.. I was getting strange or no data when receiving posted data from PHP
or from FLASH. If I do something along the lines of the listing below.. it
works and I get that data. So.. This seems like a bandaid to me. Why is the
data not in the Request.From object? What am I missing?

If Request.ContentLength > 0 Then ' not posting from a form, but there's
something in the request object

Try

Dim strmRequest As System.IO.Stream

Dim iStrmLen As Integer

Dim iBytesRead As Integer

Dim i As Integer

Dim strRequest As String

strmRequest = Request.InputStream

iStrmLen = CInt(strmRequest.Length)

Dim arrRequest(iStrmLen) As Byte

iBytesRead = strmRequest.Read(arrRequest, 0, iStrmLen)

For i = 0 To iStrmLen - 1

strRequest = strRequest & Chr(arrRequest(i))

Next i

Dim xDoc As New System.Xml.XmlDocument

Dim xReader As System.IO.TextReader

xDoc.LoadXml(strRequest)



stacey
 
B

bruce barker

the form object only contains data if the posted content type is a valid
form mime type and the data is in form format. php and flash are posting
just the xml, you other two apps are form encoding it. if you check the
content-type for php and flash, you will probably see
content-type="text/xml".

-- bruce (sqlwork.com)
 
S

Steven Cheng[MSFT]

Hi Stacey,

As for the problem you mentioned, I think Bruce's suggestion is reasonable
and generally we always use the "x-www-form-urlencoded" or
"multipart/form-data " two FORM content type. The x-www-form-urlencodes is
used to post simple ASCII datas and multipart/form-data can help posting
large binary/text datas or non-ascii datas. Here is the reference in W3C:

#17.13.4 Form content types
http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Steven Cheng[MSFT]

You're welcome Stacey. Thanks again for your posting!
Have a good day.

Regards,

Steven Cheng
Microsoft Online Support
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top