Returning Large Object in .Net 5 Getting Error: The JSON value of length 204472564 is too large and not supported

Viewed 480

I have a webservice that gets an SSRS report as a byte[] array and returns it as a class object with some other data (ids, sucess message etc...).

It works fine for any report under 100 MB. However when a report is larger than that, I get the error: The JSON value of length 204472564 is too large and not supported

I have tried setting maxJsonLength="2147483647" in the web.config.

I have tried using [DisableRequestSizeLimit] on the controller.

I have tried using [HttpPost] instead of [HttpGet]

This wasn't a problem until we upgraded to .Net 5. In .Net 4.6 the maxJsonLength="2147483647" value made it work.

It happens in IIS and on my desktop.

Any ideas how to increase that limit?

Here's the function:

        [Route("api/Report/PrintBatch")]
        [HttpPost]
        [DisableRequestSizeLimit]
        public async Task<PrintBatch> PrintBatch(string url)
        {
            try
            {
                PrintBatch printBatch = new PrintBatch();
                Byte[] report = await GetByCorrIDorBatchID(url);
                printBatch.report = Convert.ToBase64String(report);
                return printBatch;
            }
            catch (Exception ex)
            {
                Logger.LogException("Error printing batch for batchid: " + batchID + " dbname: " + dbname, ex);
            }
        }
0 Answers
Related