My current Win 2008 R2 server migrating to Azure. So that Im moving a web application to Azure Server Win 2008 R2.
Currently, I am facing the issue where it shows
"Message":"String was not recognized as a valid DateTime.","StackTrace":" at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)\r\n at System.Convert.ToDateTime(String value)\r\n at... `
Purpose of the code: Its a JQGrid library, If the code runs successfully, I will proceed to update a table. This code runs when user clicks the update button and before updating the table as validation of date.
Weird question is: My On-Prem server runs this code smoothly, all data in Azure and On-Prem server are same.
NEWLY ADDED: When I edit some rows (so far only 1 row out of 100), it works.
JQuery code snippet:
closeAfterEdit: true,
closeOnEscape: true,
reloadAfterSubmit: true,
url: '/SFI/WebService/StaffMaster.asmx/CheckEditStaff_AssignedRoster',
ajaxEditOptions: { contentType: 'application/json; charset=utf-8' },
mtype: 'post',
datatype: 'json',
serializeEditData: function (postData) {
var PrivilegeID = $('#hdnMAPrivilegeID').val();
eStaffID = $("#StaffID").val();
eStaffNo = $("#StaffNo").val(),
eNewEndDate = $("#EffectiveEnd").val();
eStaffName = $("#StaffName").val(),
eIdentificationNo = $("#IdentificationNo").val(),
eDOB = $("#DOB").val(),
eEffectiveStart = $("#EffectiveStart").val(),
eEffectiveEnd = $("#EffectiveEnd").val(),
eGradeCode = $("#GradeDetails").val(),
eStaffType = $("#StaffType").val(),
eOrgUnit = $("#OrgUnit").val(),
eEmail= $("#Email").val().toLowerCase()
return JSON.stringify(
{
StaffID: $("#StaffID").val(),
NewEndDate: $("#EffectiveEnd").val(),
OldEndDate: StaffOldEndDte
});
.
.
.
StaffOldEndDte = $("#EffectiveEnd").val();
Web Service Call in C#:
public string CheckEditStaff_AssignedRoster(string StaffID,string NewEndDate,string OldEndDate)
{
string status = "0";
bool Changed = false;
DateTime dtnew;
DateTime dtOld;
dtnew = Convert.ToDateTime(NewEndDate);
dtOld = Convert.ToDateTime(OldEndDate);
if ((dtOld != dtnew) && (dtnew < dtOld))
{
Changed = true;
}
else
{
status = "1";
}
if (Changed)
{
if (some condition...)
{
.
.
//do something...
}
else
{
status = "1";
}
}
return status;
}
After knowing some knowledge on different cultures on DateTime format, from the question's comment, I moved to search again on how to make it the same as my on-premise server to new azure server (Because I have already developed a working code in my on-premise server). Found that, i can just change the 'Region and Language' setting same as on-premise to azure. Below is the link I used.
Here is the link: From where CultureInfo.CurrentCulture reads culture