ASP.Net/Request/Request Filter — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 11:53, 26 мая 2010

Filtering the HTTP Request body using InputStream (VB.net)

<%@ Page Language="vb" %>
<%@ import namespace = "System.IO" %>
<html>
   <head>
      <title>Filtering the HTTP Request body using InputStream</title>
   </head>
<body>
<p>
<%
    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, Len, iRead As Integer
    Dim OutString As String
    Dim Found As Boolean
    
    InStream = Request.InputStream
    Len = CInt(InStream.Length)
    Dim ByteArray(Len) As Byte
    Trace.Write("Len", Len)
    iRead = InStream.Read(ByteArray, 0, Len)
    
    For iCounter = 0 to Len - 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)
%>
</p>
</body>
</html>