我有一个web API2项,我需要读取传入请求的“正文”。客户端正在与URL中的参数相对的主体中发送信息(通过“PUT”)。我一直在寻找解决方案,但一直在打墙。任何人都可以建议我如何获得这个正文?
由于
<HttpOptions>
<Route("v1/cth/test"), AcceptVerbs("PUT", "POST", "OPTIONS")>
Public Function CTHInterface(ByVal passedjson As Object) As String
Return "Hello"
End Function
答案 0 :(得分:0)
仅供参考,我终于设法到了身体。希望这有助于其他人。
<HttpOptions>
<Route("v1/cth/dev"), AcceptVerbs("PUT", "POST", "OPTIONS")>
Public Function CTHInterfaceDev() As String
Dim CTHStream As New StreamReader(HttpContext.Current.Request.InputStream)
Dim CTHBody As String = CTHStream.ReadToEnd
Return "Hello"
End Function