Hi there. Yes, this can be done. The problem is that the POST always
returns binary data, which isn't too great for working with in ASP.
However, this can be fixed easily. Below is a web page that'll
retrieve the POST as binary, then convert it to a string
representation in ASP and write it out to show what's happened:
8<- - - - - - - - 8<- - - - - - - -
<html>
<body>
<%
Sub Main()
Dim varRequest 'As Variant
Dim lngLength 'As Long
lngLength = Request.TotalBytes
varRequest = Request.BinaryRead(lngLength)
'varRequest is now a binary object
varRequest = BStr2UStr(varRequest)
'varRequest is now a string
If (varRequest <> "") Then
Response.Write "<b>Data posted was:</b><br /><code>" &
varRequest & "</code><hr />" & vbCrLf
End If
End Sub
Private Function BStr2UStr(BStr)
'Convert a Byte string to a Unicode string
On Error Resume Next
Dim lngCount 'As Long
BStr2UStr = ""
For lngCount = 1 To LenB(BStr)
BStr2UStr = BStr2UStr & Chr(AscB(MidB(BStr, lngCount, 1)))
Next
End Function
Main
%>
<form method="post">
<input type="text" name="txtTextBox" value="My text box value" />
<br />
<textarea name="txtTextArea" cols="40" rows="5">Lorem ipsum
dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.</textarea>
<br />
<input type="submit" value="submit" />
</form>
</body>
</html>
8<- - - - - - - - 8<- - - - - - - -
What you'll probably find is you want to decode the text posted now
(get rid of all the "+" and "%" values between words, etc. Here's a
function to do that properly, too:
Private Function URLDecode(ByVal Expression As String) As String
'== The inverse of the standard ASP function URLEncode()
Dim strSource 'As String
Dim strTemp 'As String
Dim strResult 'As String
Dim lngCount 'As Long
Dim lngMax 'As Long
strSource = Replace(Expression, "+", " ")
lngMax = Len(strSource)
For lngCount = 1 To lngMax
strTemp = Mid(strSource, lngCount, 1)
If strTemp = "%" Then
If (lngCount + 2) < Len(strSource) Then
strResult = strResult & Chr(CInt("&H" & Mid(strSource,
lngCount + 1, 2)))
lngCount = lngCount + 2
End If
Else
strResult = strResult & strTemp
End If
Next
URLDecode = strResult
End Function |