0

I am passing an image data from the backend to the frontend. If the image is small size everything works fine. Otherwise I am getting the following error: 'Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.' I research some suggestions but so far no luck.

    public static ModelResponse GetData(int imageID, string docType)
    {
        var imageData = DataConnection.Test.GetData(fileID).FirstOrDefault();

        ImageFileDTO imageFile = new ImageFileDTO
        {
            ImageFileData = Convert.ToBase64String(imageData.FileData)
        };

        var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
        serializer.MaxJsonLength = Int32.MaxValue;

        var result = serializer.Serialize(imageFile);
        return new ModelResponse(result);
    }

And I also set the maxJsonLenght in the web config

<system.web.extensions>
  <scripting>
    <webServices>
      <jsonSerialization maxJsonLength="50000000"/>
    </webServices>
  </scripting>
</system.web.extensions>
Lio Liov
  • 3
  • 2

1 Answers1

0
<jsonSerialization maxJsonLength="2147483644" />

Try this.

Muzaffer Galata
  • 580
  • 1
  • 9
  • 22