简体   繁体   English

在序列化之前获取POST或PUT请求正文(.NET,C#)

[英]Getting POST or PUT request body prior to serialization (.NET, C#)

We (our dev team) have a need to inspect an inbound POST or PUT request body prior to serialization. 我们(我们的开发团队)需要在序列化之前检查入站POST或PUT请求正文。

We don't need to transform or manipulate anything, simply be able to see and possibly record the body for future analysis. 我们不需要改变或操纵任何东西,只需能够看到并可能记录身体以备将来分析。

We need to look at the raw request body not the request as it was serialized. 我们需要查看原始请求正文而不是请求,因为它已被序列化。

This is a straightforward Web API app running on IIS7. 这是在IIS7上运行的简单Web API应用程序。 Our controllers are based on the system.Web.Http ApiController class. 我们的控制器基于system.Web.Http ApiController类。

I investigated finding this in the Request object, but despite it containing a plethora of information about the headers and the like, it did not seem to contain the raw request body, which is what i am looking for. 我调查了在Request对象中找到的内容,但是尽管其中包含有关标头等的大量信息,但它似乎并不包含原始的请求主体,这正是我要寻找的内容。 I did find some prior posts that described getting this through the Request.InputStream, but this does not appear to be available in .Net 4.5. 我确实找到了一些先前的文章,它们描述了如何通过Request.InputStream实现此功能,但是在.Net 4.5中似乎不可用。

Thanks for any insights. 感谢您的任何见解。

-r -r

PS .Net 4.5 PS .Net 4.5

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM