简体   繁体   English

ServiceStack:POST正文内容为NameValueCollection

[英]ServiceStack: POST body content as NameValueCollection

In a ServiceStack service or filter, is there any way to get access to the NameValueCollection parsed from a URLEncoded POST content? 在ServiceStack服务或筛选器中,是否有任何方法可以访问从URLEncoded POST内容解析的NameValueCollection

While I understand that it is parsed into the DTO as appropriate, sometimes it is valuable to have access to the arbitrary values in the name value collection. 虽然我知道可以将其适当地解析到DTO中,但有时访问名称值集合中的任意值很有价值。

I don't mind having ServiceStack parse and fill the DTO—I just also want to see the raw NameValueCollection (or equivalent data structure if ServiceStack uses its own parsing mechanism). 我不介意让ServiceStack解析并填充DTO,我也只想查看原始的NameValueCollection (如果ServiceStack使用自己的解析机制,则为等效的数据结构)。

Inside a Service you can access the POST'ed data with: 在服务内部,您可以通过以下方式访问POST的数据:

var htmlPostVar = base.Request.FormData["postName"];

See the Access HTTP specific features in services for more info on how to access HTTP Request and Response info from inside services. 有关如何从内部服务访问HTTP请求和响应信息的更多信息,请参见服务中的访问HTTP特定功能

Service基类使您可以访问Request并且可以在FormData找到POST内容,它是NameValueCollection

Request.FormData

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

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