Name
InputStream
Synopsis
inputstream = Request.InputStream
Returns a Stream object containing the body of the incoming HTTP request.
Parameters
-
inputstream
An Object variable of type Stream.
Example
The example uses a byte array to search for a specified character and
then copies that character and the remaining contents of the stream
to a string. The @
Import
directive shown in the example should be placed at the top of the
page:
<% @ Import Namespace="System.IO" %> Sub Page_Load( ) Dim InStream As Stream Dim iCounter, StreamLength, iRead As Integer Dim OutString As String Dim Found As Boolean InStream = Request.InputStream StreamLength = CInt(InStream.Length) Dim ByteArray(StreamLength) As Byte iRead = InStream.Read(ByteArray, 0, StreamLength) InStream.Close( ) For iCounter = 0 to StreamLength - 1 If Found = True Then OutString &= Chr(ByteArray(iCounter)) End If If Chr(ByteArray(iCounter)) = "A" Then Found = True OutString &= Chr(ByteArray(iCounter)) End If Next iCounter Message.Text = "Output: " & OutString End Sub
The following code can be used to post to the example page:
<html> <head> </head> <body> <form id="form1" action="InputStream.aspx" method="POST"> <h3>Name:</h3> <input type="text" name="name"> <input type="submit"> </form> </body> </html>
The code returns as output the first capital A appearing in the request body. Any characters after it are returned to the end of the stream.
Notes
This property is useful if you wish to perform byte-level filtering of the request body. ...
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.