ServiceStack request POST body as query string

I am trying to implement an IPN handler in C# and I am using ServiceStack as my backend framework. I am facing the following issue however;

I am trying to find a way to take the POST body of a request as a querystring but I fail to do so. I am using IRequest.GetRawBody(); but the POST data are returned in a formatted way to make it readable.

Is there any way to easily take the POST body as a querystring? I want something similar to PHP's $_POST so I can ecrypt the data with HMAC SHA256 but I can find a way to do it without writing a helper class with hardcoded details about the POST request body. I've tried searching online and ServiceStack's documentation but I did not find anything useful.

Any help will be very appreciated, thanks in advance!


The QueryString is on the URL not the Request Body. If you just want access to the raw Request body that's posted you can have your Request DTO implement IRequiresRequestStream which tells ServiceStack to skip deserializing the body so you can deserialize it yourself, eg:

public class MyRequest : IRequiresRequestStream
{
    public Stream RequestStream { get; set; }
}
public class MyServices : Service
{
    public object Any(MyRequest request)
    {
        var bytes = request.RequestStream.ReadFully();
        var text = bytes.FromUtf8Bytes();
        ...
    }
}
链接地址: http://www.djcxy.com/p/68720.html

上一篇: IISExpress从远程计算机返回503错误

下一篇: ServiceStack请求POST正文作为查询字符串