1

I am posting an object to a webapi method. object looks as such

public class SendRequest
{
    public string APIKey { get; set; }
    public string Message { get; set; }
}

I have an example, where my message is REALLY big (27mb). On posting it is always null.

Note - my SendRequest is not null, but my Message property is. Following similar articles, I configured my web.config as such

<httpRuntime 
    targetFramework="4.5.1" 
    maxRequestLength="2147483647" 
    requestValidationMode="4.0" 
    executionTimeout="110" />

and

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="2147483648" />
  </requestFiltering>
</security>

but I am still not winning.

The crazy thing is that it's just the single property thats null (APIKey is passed correctly) so it can't be IIS blocking it can it?

Am I just failing on deserializing?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Crudler
  • 2,194
  • 3
  • 30
  • 57

2 Answers2

0

Might be a silly question - but are you sending / posting your content with a multipart/form-data content type header?

I noticed when I was doing MVC file uploads, even small files would fail to upload, because the client needed to have the form post marked as a multi-part form.

Baaleos
  • 1,703
  • 12
  • 22
  • plan text. application/json – Crudler Feb 19 '18 at 17:28
  • I am not entirely sure - but I have had exceptions occur in the past with Newtonsoft.Json where it cannot deserialize huge files. Try it in a demo project - can you load the 27 mb file and deserialize it? Perhaps your issue is due to the size of the file and its inability to deserialize it once it arrives, opposed to the actual idea that it isnt sending in the first place. – Baaleos Feb 19 '18 at 17:35
0

I found this:

            <webServices>
                <jsonSerialization maxJsonLength="50000000"/>
            </webServices>

Here

Can I set an unlimited length for maxJsonLength in web.config?

If you are sending this as application/json encoding/content type - then it is conceivable that you web.config needs to have its maxJsonLength increased to accomodate your huge json file. It may not be anything to do with the request size in this case, but rather the max json length.

Baaleos
  • 1,703
  • 12
  • 22