Вопрос

Through my testing, it seems that servicestack is automatically URL decoding any parameters sent through the query string of a GET request, but does not automatically decode params sent via a POST request.

Is there anyway that I can check the HTTP method and decode through my code for POST requests?

EDIT

My methods are derived from a class which implements the RestServiceBase class from Servicestack.net.

Is there any way to check the HTTP method from the current request via RestServiceBase?

Это было полезно?

Решение

What is the wire format? i.e. is it application/json or application/x-www-form-urlencoded ? because only application/x-www-form-urlencoded Content-Type's should be encoded.

Now if your POST'ing with a C# ServiceClient then we don't support POST'ing application/x-www-form-urlencoded and it's likely that JSON or XML, etc (depends on the ServiceClient) is being posted instead which doesn't require Url Encoding.

If you're POST'ing from jQuery then it should automatically be doing the url encoding for you.

Either way, can you post the HTTP Request payload so we can see what's going on.

Другие советы

I use jQuery encoding in client side:

var sear = htmlEncode($("#Search").html());
.
.
.
function htmlEncode(value) {
    if (typeof (value) != "undefined") {
        return $('<div/>').text(value).html();
    }
    return "";
}

function htmlDecode(value) {
    if (typeof (value) != "undefined") {
        return $('<div/>').html(value).text();
    }
    return "";
} 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top