I stored images in database in base_64 format. Fetching that data from a controller to html using Ajax. While fetching record from in controller, I get the following error in custom filter exception:
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
cshtml - Ajax callled:
function imagepop(no) {
$.ajax({
type: "POST",
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
url:"/Controller/GetImage",
data: { 'No': no, 'filetype': obj, 'pageNo': pageNo },
success: function (result) {
debugger;
$("#loader_Prcessing").hide();
if (result.Status == "200") {
}
}
});
}
Controller:
public JsonResult GetImage(string no, string filetype, string pageNo)
{
var jsonResult = Json(OutputInfo.lstUploadImgVideoDoc, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
return Json(jsonResult);
}
web.config:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647"/>
</webServices>
</scripting>
</system.web.extensions>
I stored images in database in base_64 format. Fetching that data from a controller to html using Ajax. While fetching record from in controller, I get the following error in custom filter exception:
Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.
cshtml - Ajax callled:
function imagepop(no) {
$.ajax({
type: "POST",
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
url:"/Controller/GetImage",
//data: arr,
data: { 'No': no, 'filetype': obj, 'pageNo': pageNo },
//dataType: "json",
success: function (result) {
debugger;
$("#loader_Prcessing").hide();
if (result.Status == "200") {
}
}
});
}
Controller:
public JsonResult GetImage(string no, string filetype, string pageNo)
{
var jsonResult = Json(OutputInfo.lstUploadImgVideoDoc, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
return Json(jsonResult);
}
web.config:
<system.web.extensions>
<scripting>
<webservices>
<jsonserialization maxjsonlength="2147483647">
Is there any solution for this at the config level? OR any suggestion with minimum changes in code.
What I have tried:
I tried many thing as suggest on google but not succeded,Please help on this