V 16.1.1-FileUpload: JSON Error in OnUploadComplete Event - Sys.ArgumentException: Cannot deserialize.
See original GitHub issueThe AJAX Control Toolkit <16.1.1>
The installation method
- NuGet package
Steps to reproduce the bug
The user uploads the file using Upload button in the FileUpload control. The file is uploaded in the TEMP folder of the server (Windows\Temp_AjaxFileUpload folder) Then in the OnUploadComplete event -
- Get the Byte Array of file data from AjaxFileUploadEventArgs parameter of the event
- Try inserting it in SQL Server table. While the Parameters for the SQL stored procedure are being built, on the last “String” parameter suddenly the code jumps to the event error handler and shows the following error in a dialog box:
0x800a139e - JavaScript runtime error: Sys.ArgumentException: Cannot deserialize. The data does not correspond to valid JSON.
The procedure in the ScriptResource.axd which throws the error is:
`Sys.Serialization.JavaScriptSerializer.deserialize = function Sys$Serialization$JavaScriptSerializer$deserialize(data, secure) {
var e = Function._validateParams(arguments, [
{name: “data”, type: String},
{name: “secure”, type: Boolean, optional: true}
]);
if (e) throw e;
if (data.length === 0) throw Error.argument(‘data’, Sys.Res.cannotDeserializeEmptyString);
try {
var exp = data.replace(Sys.Serialization.JavaScriptSerializer._dateRegEx, “$1new Date($2)”);
if (secure && Sys.Serialization.JavaScriptSerializer._jsonRegEx.test(
exp.replace(Sys.Serialization.JavaScriptSerializer._jsonStringRegEx, ''))) throw null;
return eval('(' + exp + ')');
}
catch (e) {
throw Error.argument('data', Sys.Res.cannotDeserializeInvalidJson);
}
} `
This is happening in Version 16.1.1 earlier versions 15.x were running fine. My code has not changed.
This happens in IE 11, Edge, Firefox and Chrome browsers (latest versions). Others have not been tested.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
UPDATE: I installed NuGet package for version 16.1.0 and it works. So the latest version 16.1.1 has some issue. Please note that I have NOT added the TempFolder attribute for the AjaxControlToolkit in the web.config that was introduced in the 16.1.1
Since we still haven’t received the requested information, I’m closing this issue. Feel free to reopen it once you have any additional info regarding the error.