Get the raw body of posted web page

I needed to get at the raw body of a posted web page using asp.net here's the code I came up with...

Dim body As System.IO.Stream = Request.InputStream
Dim encoding As System.Text.Encoding = Request.ContentEncoding
Dim reader As System.IO.StreamReader = New System.IO.StreamReader(body, encoding)

Console.WriteLine("Client data content type {0}", Request.ContentType)
Console.WriteLine("Client data content length {0}", Request.ContentLength)

Dim s As String = reader.ReadToEnd()
Console.WriteLine(server.UrlDecode(s))
Console.WriteLine("End of client data:")
body.Close()
reader.Close()

0 comments: