I am facing an issue with the POST function in my code. While string and integer values are reaching the Controller without any problem, double values are not being received on the server side. Interestingly, when I test on my local machine, everything works fine. Can anyone explain why this behavior is occurring?
Below are snippets of my JS and Controller codes:
var cmbvdf = $('#cmbvolDec').data('kendoComboBox');
var cmbvdfval = cmbvdf.value();
var cmbadf = $('#cmbamtDec').data('kendoComboBox');
var cmbadfval = cmbadf.value();
var cmbCur = $('#cmbCurrency').data('kendoComboBox');
var cmbcurrency = cmbCur.value();
var cmtheme = $('#cbmTheme').data('kendoComboBox');
var cmbvaltheme = cmtheme.value();
var cmblang = $('#cmbLanguage').data('kendoComboBox');
var cmbvallang = cmblang.value();
var custname = $("#txtCustName").val();
var websitetitle = $("#txtWebName").val();
var zoom = $("#txtZoom").val();
var lat1 = $("#txtLat1").val();
var lon1 = $("#txtLon1").val();
var url = '../Setting/SaveRecords';
$.ajax({
type: "POST",
url: url,
data:JSON.stringify({ 'volumeDecimalFactor': cmbvdfval, 'amountDecimalFactor': cmbadfval, 'currency': cmbcurrency, 'theme': cmbvaltheme, 'language': cmbvallang, 'customerName': custname, 'lat1': lat1, 'lon1': lon1, 'web': websitetitle, 'zoom': zoom }),
contentType: 'application/json, charset=utf-8',
traditional: true,
success: function (data) {
//do something
}
});
This is how my C# Controller looks like:
public ActionResult SaveRecords(string volumeDecimalFactor, string amountDecimalFactor, string currency, string theme, string language, string customerName, double? lat1, double? lon1, string web, double? zoom)
{
//When testing locally, I can retrieve double values without any issues.
//However, after publishing to the server, the values come back as null!
}
NOTE:
In the Google Chrome Network Tab, here is the Request Payload:
amountDecimalFactor: "2"
currency: "4"
customerName: "Fuel Card System"
language: "1"
lat1: "41.071789"
lon1: "28.980325"
theme: "4"
volumeDecimalFactor: "2"
web: "WebProject"
zoom: "5.2"
It's worth mentioning that my local PC and the Server are located in different countries.