Using .NET JavaScriptSerializer.Deserialize with DateTime from client

You are right, @friendlycello. Unfortunally, JSON.stringify() removes backslashes from this \/Date(ticks)\/ .Net serializer DateTime format.

I wrote a custom function that adjusts the output from JSON.stringify(), including these backslashes. So, I can keep almost untoched, only replacing from JSON.stringify() to customJSONstringify() in $.ajax() data: param.

function customJSONstringify(obj) {
    return JSON.stringify(obj).replace(/\/Date/g, "\\\/Date").replace(/\)\//g, "\)\\\/")
}

Eduardo provided a solution on the JavaScript side. You also have the option of correcting the issue on the server side.

// C# Side
var obj = Regex.Replace(json, @"/Date\((\-?\d*)\)/", @"\/Date($1)\/")

Note that I used a single replace. This is safer and more accurate than using two replace(). The same expression can be used to replace the expression in the JavaScript example.

// Safer version of function using a single replace
function customJSONstringify(obj) {
    return JSON.stringify(obj).replace(/\/Date\((\-?\d*)\)\//g, "\\/Date($1)\\/");
}

Two calls to replace() could cause the second replace to replace text that had nothing to do with the data. Note to be even safer the expression can be updated to only replace instances of /Date(.\*)/ that are preceded and followed by a single quote. That would ensure that if there was text describing the /Date(.\*)/ syntax it wouldn't get replaced.