Filtering the HTTP Request body using InputStream : Request « Page Lifecycle « ASP.NET Tutorial






<html>
   <head>
      <title>Submit a named parameter via POST</title>
   </head>
<body>

   <form id="form1" action="NextPage.aspx" method="POST">
      <h3>Name:</h3>
      <input type="text" name="name">
      <input type="submit">
   </form>

</body>
</html>

File: NextPage.aspx
<%@ Page Language="vb" %>
<%@ import namespace = "System.IO" %>
<html>
   <head>
      <title>Filtering the HTTP Request body using InputStream</title>
   </head>
<body>



<%
Dim intvar As Integer
intvar = Request.TotalBytes
Response.Write("The size of the current request body is: <br>")
Response.Write(intvar & " bytes.<br>")

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
Trace.Write("StreamLength", StreamLength)
iRead = InStream.Read(ByteArray, 0, StreamLength)

For iCounter = 0 to StreamLength - 1
   If Found = True Then
      OutString = OutString & Chr(ByteArray(iCounter))
   End If
   If Chr(ByteArray(iCounter)) = "A" Then
      Trace.Write("Found", "Found an 'A'")
      Found = True
      OutString = OutString & Chr(ByteArray(iCounter))
   End If
   Trace.Write("Loop Number", iCounter)
   Trace.Write("CurrentChar", Chr(ByteArray(iCounter)))
Next iCounter

Response.Write("Output: " & OutString)
%>


</body>
</html>








5.8.Request
5.8.1.Get Request.UserLanguages
5.8.2.Request.UrlReferrer
5.8.3.Request.QueryString
5.8.4.Request.Cookies
5.8.5.Get browser information
5.8.6.Request.ServerVariables
5.8.7.Filtering the HTTP Request body using InputStream
5.8.8.Showing Parameters via the Params Collection in ASP.NET
5.8.9.Getting cookie values
5.8.10.Displaying additional path information in ASP.NET
5.8.11.Showing QueryString values via the QueryString Collection in ASP.NET
5.8.12.Displaying the HTTP headers collection in ASP.NET
5.8.13.Displaying the Request.FilePath property in ASP.NET
5.8.14.Request.Headers