Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the unit for the value for the aspnet:MaxJsonDeserializerMembers property in appSettings?

Tags:

c#

asp.net-mvc

I tried to increase the length of JSON that can be parsed by setting the following config property in Web.config.

<add key="aspnet:MaxJsonDeserializerMembers" value="4194304" />

I am not too sure what the unit of measurement of the value is. Is it in bytes or something else?

like image 792
Saravana Avatar asked May 21 '14 07:05

Saravana


2 Answers

The unit of measure is the # of items (key/value pairs) that can be deserialized. If your JSON has 500 members (key/value pairs) and your limit is 400 then it would fail.

http://msdn.microsoft.com/en-us/library/hh975440.aspx

You must be careful making this limit too high. You could easily DOS your server by submitting frequent requests with large JSON payloads and forcing your server to process them. By keeping the number low the server will terminate the request before processing begins.

like image 126
Josh Avatar answered Sep 26 '22 02:09

Josh


Based on the source code of JsonValueProviderFactory, I would say the aspnet:MaxJsonDeserializerMembers refers to a total number of key/value pairs in JSON request, irrespective of whether they are nested or not.

like image 25
Herman Kan Avatar answered Sep 26 '22 02:09

Herman Kan