简体   繁体   中英

Large property always null on post

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM