I have the following controller action:
public ActionResult AjaxQuantity(int productId = 0, double quantity = 0d, int periodId = 0)
{
...
}
and appropriate ajax request:
function Quantity(productId, quantity, periodId) {
$.ajax({
url: "@(Url.Action("AjaxQuantity"))",
cache: false,
type: "GET",
data: { productId: productId, quantity: quantity, periodId: periodId },
error: function () {
Server503();
}
});
};
Also, have a culture with a comma as decimal separator.
When I do ajax request with, for example, "12,34" as quantity, inside controller action I get quantity as 1234d.
If I change type of ajax request to "POST", then I get desired quantity inside action as 12,34d.
What's happening with GET request? Look's like in GET request culture not used (comma is simple stript off).
The thing is that
','is a reserved URI character so you are not able to use it in GET parameters.POST parameters are send as request body, because of that
','could be used there as well.From Uniform Resource Identifiers (URI): Generic Syntax 2.2. Reserved Characters