Saturday, July 23, 2011

Access Content of Request in C# (ASP .NET)

You can access the content of the HTTP Request like this:

byte[] bytes = Request.BinaryRead(Request.ContentLength);

If the content-type of the request is text/xml you can do this:

byte[] bytes = Request.BinaryRead(Request.ContentLength);
System.Text.Encoding enc = System.Text.Encoding.UTF8;
string XmlData = enc.GetString(bytes);

No comments: