Access post data directly

前端 未结 6 813
时光说笑
时光说笑 2020-12-15 02:45

I have an action in one of my controllers that is going to receive HTTP POST requests from outside of my MVC website.

All these POST requests will have the same par

6条回答
  •  轮回少年
    2020-12-15 03:15

    I was trying to access the POST data after I was inside of the MVC controller. The InputStream was already parsed by the controller so I needed to reset the position of the InputStream to 0 in order to read it again.

    This code worked for me...

     HttpContext.Current.Request.InputStream.Position = 0;
     var result = new System.IO.StreamReader(HttpContext.Current.Request.InputStream).ReadToEnd();
    

提交回复
热议问题