Search code examples
c#asp.netrequesthttp-postpayload

How to display request payload value in aspx page


One of our angular2 application is posting some data to an aspx page (using HTTPPOST). I could see the posted values under Network in Developer Tools (in browser).

I just wanted to pass that value to another webservice or to display in the page body itself.

Is that possible?


Solution

  • str = Request.InputStream;
    // Find number of bytes in stream.
    strLen = Convert.ToInt32(str.Length);
    // Create a byte array.
    byte[] strArr = new byte[strLen];
    // Read stream into byte array.
    strRead = str.Read(strArr, 0, strLen);
    
    // Convert byte array to a text string.
    strmContents = "";
    for (counter = 0; counter < strLen; counter++)
    {
        strmContents = strmContents + strArr[counter].ToString();            
    }