Getting the raw Request in ASP.NET MVC

前端 未结 2 1470
-上瘾入骨i
-上瘾入骨i 2021-01-03 20:09

I need to get the raw request string. Below is an example of the http request sent to the Controller. Actually, I need Post data (last line). How can I get that?

Not

2条回答
  •  借酒劲吻你
    2021-01-03 20:56

    At that point the stream has already been read to the end. You need to set the position of the InputStream back to the beginning before you can read it yourself.

    Request.InputStream.Position = 0;
    var input = new StreamReader(Request.InputStream).ReadToEnd();
    

提交回复
热议问题