Hi,
A few days ago I posted about how we can send XML data as a post request to any URL. You can read the stuff here. After that many people have asked me on how we can read the data when data is sent as a Post Request.
Reading data when it is sent as a post request value is very simple. We use the Request.InputStream to read the incoming stream request. Here is a glimpse of code to work with the same.
byte[] b = new byte[Request.ContentLength];
Request.InputStream.Read(b, 0, Request.ContentLength);
Here we first get the length of the request and then read the same in an array of byte.
We can convert the bytes into a string by using correct encoding. (Note: I am using the UTF8 encoding for example).
string s = System.Text.UTF8Encoding.UTF8.GetString(b);
That’s all we have to do to read the data send as post. Now we can do whatever we want to do with the request value.
Vikram