The request body is too large (the string in the parameter object is too large)

I have an MVC method:

public void PushFile([FromBody]FileTransport fileData) 

Grade:

 public class FileTransport { public string fileData; } 

In fileData, I put byte[] from the file converted to string (UTF-8), so the string can be large.

Problem: if the string is too large (somewhere above 15000 characters), the fileData parameter fileData null . If the line is not so big, everything works fine, and the parameter is as it should be.

How can I allow MVC to accept larger strings, or do I need to pre-compress the string somehow? EDIT: Already tried:

 <system.web.extensions> <scripting> <webServices> <jsonSerialization maxJsonLength="2147483644"/> </webServices> </scripting> </system.web.extensions> 

But does not work. Maybe because MVC uses JSON.NET instead of regular JsonSerializer?

+4
source share
3 answers

Have you tried to increase the maximum request length?

 <system.web> <httpRuntime maxRequestLength="{REQUEST_LENGTH}"/> <system.web> 
+2
source

The simple point is you don't put a string in the url. Just. Add it as a payload. URLs are search locators, not "content carriers."

0
source

I realized that this has nothing to do with the length of the content. If it seems that Json is incorrectly encoding some characters on the sender side, this is when the MVC controller received zero.

0
source

All Articles