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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







615















I am using the autocomplete feature of jQuery. When I try to retrieve the list of more then 17000 records (each won't have more than 10 char length), it's exceeding the length and throws the error:




Exception information:

Exception type: InvalidOperationException

Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.




Can I set an unlimited length for maxJsonLength in web.config? If not, what is the maximum length I can set?










share|improve this question




















  • 1





    Something to mention which may be pretty obvious so please excuse me if you've already thought if it; the Json string also includes the curly brackets around each record, the quotation marks around each field name [and value], as well as the field name and value. So it may be useful to set the field name as a single character and also make sure that if the value is not a string, that you set the field type correctly so it doesn't contain quotation marks.

    – MichaelJTaylor
    May 3 '16 at 9:25




















615















I am using the autocomplete feature of jQuery. When I try to retrieve the list of more then 17000 records (each won't have more than 10 char length), it's exceeding the length and throws the error:




Exception information:

Exception type: InvalidOperationException

Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.




Can I set an unlimited length for maxJsonLength in web.config? If not, what is the maximum length I can set?










share|improve this question




















  • 1





    Something to mention which may be pretty obvious so please excuse me if you've already thought if it; the Json string also includes the curly brackets around each record, the quotation marks around each field name [and value], as well as the field name and value. So it may be useful to set the field name as a single character and also make sure that if the value is not a string, that you set the field type correctly so it doesn't contain quotation marks.

    – MichaelJTaylor
    May 3 '16 at 9:25
















615












615








615


128






I am using the autocomplete feature of jQuery. When I try to retrieve the list of more then 17000 records (each won't have more than 10 char length), it's exceeding the length and throws the error:




Exception information:

Exception type: InvalidOperationException

Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.




Can I set an unlimited length for maxJsonLength in web.config? If not, what is the maximum length I can set?










share|improve this question
















I am using the autocomplete feature of jQuery. When I try to retrieve the list of more then 17000 records (each won't have more than 10 char length), it's exceeding the length and throws the error:




Exception information:

Exception type: InvalidOperationException

Exception message: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.




Can I set an unlimited length for maxJsonLength in web.config? If not, what is the maximum length I can set?







asp.net asp.net-mvc json






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 15 '15 at 15:02









Jim G.

9,5831683139




9,5831683139










asked Jul 20 '09 at 6:38









PrasadPrasad

26.8k60133196




26.8k60133196








  • 1





    Something to mention which may be pretty obvious so please excuse me if you've already thought if it; the Json string also includes the curly brackets around each record, the quotation marks around each field name [and value], as well as the field name and value. So it may be useful to set the field name as a single character and also make sure that if the value is not a string, that you set the field type correctly so it doesn't contain quotation marks.

    – MichaelJTaylor
    May 3 '16 at 9:25
















  • 1





    Something to mention which may be pretty obvious so please excuse me if you've already thought if it; the Json string also includes the curly brackets around each record, the quotation marks around each field name [and value], as well as the field name and value. So it may be useful to set the field name as a single character and also make sure that if the value is not a string, that you set the field type correctly so it doesn't contain quotation marks.

    – MichaelJTaylor
    May 3 '16 at 9:25










1




1





Something to mention which may be pretty obvious so please excuse me if you've already thought if it; the Json string also includes the curly brackets around each record, the quotation marks around each field name [and value], as well as the field name and value. So it may be useful to set the field name as a single character and also make sure that if the value is not a string, that you set the field type correctly so it doesn't contain quotation marks.

– MichaelJTaylor
May 3 '16 at 9:25







Something to mention which may be pretty obvious so please excuse me if you've already thought if it; the Json string also includes the curly brackets around each record, the quotation marks around each field name [and value], as well as the field name and value. So it may be useful to set the field name as a single character and also make sure that if the value is not a string, that you set the field type correctly so it doesn't contain quotation marks.

– MichaelJTaylor
May 3 '16 at 9:25














27 Answers
27






active

oldest

votes


















671














NOTE: this answer applies only to Web services, if you are returning JSON from a Controller method, make sure you read this SO answer below as well: https://stackoverflow.com/a/7207539/1246870





The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k).



You can set the MaxJsonLength property on your web.config:



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





share|improve this answer





















  • 145





    It is an integer so the max value you can set is: 2147483644

    – David Espart
    Sep 9 '10 at 10:43






  • 54





    @despart: You mean 2 147 483 647.

    – Dercsár
    Jul 28 '11 at 11:27






  • 6





    @kmcc049, IMO the values aren't wrong because if you look at the question, the OP is not asking "what's the default value of maxJsonLength?" (BTW, the second most voted answer is answering this, wrong question), he's trying to set this property to "unlimited", but since is an Integer, the maximum value possible is 2147483647 as @depsart and @Descár point out.

    – CMS
    Sep 23 '11 at 14:49






  • 11





    Great but note @David Murdoch's answer below if you're having this problem when using MVC's return Json() or something

    – BritishDeveloper
    Mar 13 '12 at 8:55






  • 2





    @ Dercsár: whats the point? 2147483644 is the biggest integer perfectly divisible by 1024.

    – naveen
    Jun 27 '12 at 10:34



















427














If you are using MVC 4, be sure to check out this answer as well.





If you are still receiving the error:




  • after setting the maxJsonLength property to its maximum value in web.config

  • and you know that your data's length is less than this value

  • and you are not utilizing a web service method for the JavaScript serialization


your problem is is likely that:




The value of the MaxJsonLength property applies only to the internal JavaScriptSerializer instance that is used by the asynchronous communication layer to invoke Web services methods. (MSDN: ScriptingJsonSerializationSection.MaxJsonLength Property)




Basically, the "internal" JavaScriptSerializer respects the value of maxJsonLength when called from a web method; direct use of a JavaScriptSerializer (or use via an MVC action-method/Controller) does not respect the maxJsonLength property, at least not from the systemWebExtensions.scripting.webServices.jsonSerialization section of web.config.



As a workaround, you can do the following within your Controller (or anywhere really):



var serializer = new JavaScriptSerializer();

// For simplicity just use Int32's max value.
// You could always read the value from the config section mentioned above.
serializer.MaxJsonLength = Int32.MaxValue;

var resultData = new { Value = "foo", Text = "var" };
var result = new ContentResult{
Content = serializer.Serialize(resultData),
ContentType = "application/json"
};
return result;




This answer is my interpretation of this asp.net forum answer.






share|improve this answer





















  • 5





    Your answer was really helpful as I am using the Json() action result method in asp.net mvc.

    – jessegavin
    Jan 9 '12 at 15:58






  • 3





    Yep I was a Json() suffer too. Thanks!

    – BritishDeveloper
    Mar 13 '12 at 8:54






  • 3





    Although it is completely correct and deserving of its place, this is one of those questions where it's worth reading past the top answer :). Thanks!

    – Nigel
    Apr 19 '12 at 8:14






  • 3





    If you're using MVC4 please see @fanisch answer as well.

    – Beyers
    Jan 11 '13 at 10:44






  • 3





    How about Deserialization? I met this error at action's model binding.

    – guogangj
    May 17 '17 at 11:45



















312














In MVC 4 you can do:



protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
{
return new JsonResult()
{
Data = data,
ContentType = contentType,
ContentEncoding = contentEncoding,
JsonRequestBehavior = behavior,
MaxJsonLength = Int32.MaxValue
};
}


in your controller.



Addition:



For anyone puzzled by the parameters you need to specify, a call could look like this:



Json(
new {
field1 = true,
field2 = "value"
},
"application/json",
Encoding.UTF8,
JsonRequestBehavior.AllowGet
);





share|improve this answer





















  • 6





    I can confirm that the above works like a charm in MVC 4, thank you fanisch.

    – Beyers
    Jan 11 '13 at 10:42






  • 9





    I can confirm as well. Putting this code inside a base controller is definitely the cleanest approach proposed.

    – parliament
    Mar 5 '13 at 9:13






  • 12





    This also works by just adding "MaxJsonLength = Int32.MaxValue" to the individual action result. In case the change is not desired controller or project wide.

    – Hypnovirus
    Apr 18 '13 at 2:57








  • 3





    This is the best answer. The MaxJsonLength can be configured per controller.

    – liang
    Sep 7 '14 at 10:32






  • 3





    WARNING: this solution disables the compression (if requested) of the response. Add this filter on your action: stackoverflow.com/questions/3802107/…

    – Gorgi Rankovski
    Dec 22 '15 at 14:55





















58














You can configure the max length for json requests in your web.config file:



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


The default value for maxJsonLength is 102400. For more details, see this MSDN page: http://msdn.microsoft.com/en-us/library/bb763183.aspx






share|improve this answer





















  • 1





    What is the stored value in this integer representing? Is this some sort of count of character? I guess what I am asking is, why an integer is being used? Thanks!

    – eaglei22
    Mar 20 '17 at 12:21











  • @eaglei22 the number represents how many bytes can be used for the maxJsonLength. As M4N mentioned, 102400 is the default (100KB).

    – Jacob Plonke
    Jul 11 '17 at 12:25











  • this is not worked for me and i not used webservices.

    – kalai
    Mar 28 at 8:45



















33














I was having this problem in ASP.NET Web Forms. It was completely ignoring the web.config file settings so I did this:



        JavaScriptSerializer serializer = new JavaScriptSerializer();

serializer.MaxJsonLength = Int32.MaxValue;

return serializer.Serialize(response);


Of course overall this is terrible practice. If you are sending this much data in a web service call you should look at a different approach.






share|improve this answer





















  • 1





    did this work for you? where did you place this code?

    – user1012598
    Feb 10 '15 at 6:12











  • Our problem was because we had a textarea that allowed for HTML and people were embedding images as HTML which caused the entry to become very large and JSON serializer to fail. I guess if it can be done users will do it...

    – Marko
    Jul 27 '15 at 15:09











  • Please describe where we should put this code... @Flea

    – Koray Durudogan
    Nov 14 '16 at 12:05











  • @KorayDurudogan - I put this in the Ajax method that was returning the response, so in my controller. Hope that helps!

    – Flea
    Nov 15 '16 at 19:42











  • I am not challenging your response, but trying to get a better idea of what better approaches there are. I have a query that depending on what the user's criteria is will determine the result size. I return a JsonResult, Would it matter if I returned an excel file?

    – eaglei22
    Mar 20 '17 at 12:24



















26














if you are still getting error after web.config setting like following:




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





I solved it by following:



   public ActionResult/JsonResult getData()
{
var jsonResult = Json(superlargedata, JsonRequestBehavior.AllowGet);
jsonResult.MaxJsonLength = int.MaxValue;
return jsonResult;
}


I hope this should help.






share|improve this answer


























  • Setting the maxJsonLength in the web.config is unnesseary, setting the jsonResult.MaxJsonLength should suffice (at least it did for me (MVC5))

    – hormberg
    May 18 '18 at 7:45



















21














I fixed it.



//your Json data here
string json_object="........";
JavaScriptSerializer jsJson = new JavaScriptSerializer();
jsJson.MaxJsonLength = 2147483644;
MyClass obj = jsJson.Deserialize<MyClass>(json_object);


It works very well.






share|improve this answer


























  • Awesome! This is the only solution that worked for me and its better anyways since its not a global change. Thanks!

    – Sealer_05
    Nov 6 '15 at 19:41





















16














if, after implementing the above addition into your web.config, you get an “Unrecognized configuration section system.web.extensions.” error then try adding this to your web.config in the <ConfigSections> section:



            <sectionGroup name="system.web.extensions" type="System.Web.Extensions">
<sectionGroup name="scripting" type="System.Web.Extensions">
<sectionGroup name="webServices" type="System.Web.Extensions">
<section name="jsonSerialization" type="System.Web.Extensions"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>





share|improve this answer



















  • 4





    I was having this problem. However, this answer did not work for me. Instead of adding the <sectionGroup> element described here, I just moved the whole newly added <system.web.extensions> block to the very end of my web.config... right before </configuration>. Then it worked.

    – ClearCloud8
    Nov 2 '12 at 15:09











  • This helped, but in my situation I needed to change your fourth line to <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>, as seen on this page: forums.asp.net/t/1446510.aspx/1

    – Nathan
    Jun 25 '13 at 13:54













  • @ClearCloud8 Get that comment spread across this page immediately.

    – Jack Nutkins
    Jan 25 '16 at 0:04



















14





+50









I followed vestigal's answer and got to this solution:



When I needed to post a large json to an action in a controller, I would get the famous "Error during deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.rnParameter name: input value provider".



What I did is create a new ValueProviderFactory, LargeJsonValueProviderFactory, and set the MaxJsonLength = Int32.MaxValue in the GetDeserializedObject method



public sealed class LargeJsonValueProviderFactory : ValueProviderFactory
{
private static void AddToBackingStore(LargeJsonValueProviderFactory.EntryLimitedDictionary backingStore, string prefix, object value)
{
IDictionary<string, object> dictionary = value as IDictionary<string, object>;
if (dictionary != null)
{
foreach (KeyValuePair<string, object> keyValuePair in (IEnumerable<KeyValuePair<string, object>>) dictionary)
LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);
}
else
{
IList list = value as IList;
if (list != null)
{
for (int index = 0; index < list.Count; ++index)
LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakeArrayKey(prefix, index), list[index]);
}
else
backingStore.Add(prefix, value);
}
}

private static object GetDeserializedObject(ControllerContext controllerContext)
{
if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
return (object) null;
string end = new StreamReader(controllerContext.HttpContext.Request.InputStream).ReadToEnd();
if (string.IsNullOrEmpty(end))
return (object) null;

var serializer = new JavaScriptSerializer {MaxJsonLength = Int32.MaxValue};

return serializer.DeserializeObject(end);
}

/// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
/// <returns>A JSON value-provider object for the specified controller context.</returns>
/// <param name="controllerContext">The controller context.</param>
public override IValueProvider GetValueProvider(ControllerContext controllerContext)
{
if (controllerContext == null)
throw new ArgumentNullException("controllerContext");
object deserializedObject = LargeJsonValueProviderFactory.GetDeserializedObject(controllerContext);
if (deserializedObject == null)
return (IValueProvider) null;
Dictionary<string, object> dictionary = new Dictionary<string, object>((IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase);
LargeJsonValueProviderFactory.AddToBackingStore(new LargeJsonValueProviderFactory.EntryLimitedDictionary((IDictionary<string, object>) dictionary), string.Empty, deserializedObject);
return (IValueProvider) new DictionaryValueProvider<object>((IDictionary<string, object>) dictionary, CultureInfo.CurrentCulture);
}

private static string MakeArrayKey(string prefix, int index)
{
return prefix + "[" + index.ToString((IFormatProvider) CultureInfo.InvariantCulture) + "]";
}

private static string MakePropertyKey(string prefix, string propertyName)
{
if (!string.IsNullOrEmpty(prefix))
return prefix + "." + propertyName;
return propertyName;
}

private class EntryLimitedDictionary
{
private static int _maximumDepth = LargeJsonValueProviderFactory.EntryLimitedDictionary.GetMaximumDepth();
private readonly IDictionary<string, object> _innerDictionary;
private int _itemCount;

public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
{
this._innerDictionary = innerDictionary;
}

public void Add(string key, object value)
{
if (++this._itemCount > LargeJsonValueProviderFactory.EntryLimitedDictionary._maximumDepth)
throw new InvalidOperationException("JsonValueProviderFactory_RequestTooLarge");
this._innerDictionary.Add(key, value);
}

private static int GetMaximumDepth()
{
NameValueCollection appSettings = ConfigurationManager.AppSettings;
if (appSettings != null)
{
string values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
int result;
if (values != null && values.Length > 0 && int.TryParse(values[0], out result))
return result;
}
return 1000;
}
}


}



Then, in the Application_Start method from Global.asax.cs, replace the ValueProviderFactory with the new one:



protected void Application_Start()
{
...

//Add LargeJsonValueProviderFactory
ValueProviderFactory jsonFactory = null;
foreach (var factory in ValueProviderFactories.Factories)
{
if (factory.GetType().FullName == "System.Web.Mvc.JsonValueProviderFactory")
{
jsonFactory = factory;
break;
}
}

if (jsonFactory != null)
{
ValueProviderFactories.Factories.Remove(jsonFactory);
}

var largeJsonValueProviderFactory = new LargeJsonValueProviderFactory();
ValueProviderFactories.Factories.Add(largeJsonValueProviderFactory);
}





share|improve this answer
























  • I did every thing i can, only your answer saved my day, this should have been accepted answer

    – Muhammad Waqas Aziz
    Aug 5 '18 at 14:54











  • With this code we are able to override MVC controller max json Deserializetion limit of 4 mb, but is there a way to override web-api controller max json Deserializetion limit

    – Muhammad Waqas Aziz
    Aug 6 '18 at 4:05



















10














you can write this line into Controller



json.MaxJsonLength = 2147483644;


you can also write this line into web.config



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


`



To be on the safe side, use both.






share|improve this answer

































    9














    If you are getting this error from the MiniProfiler in MVC then you can increase the value by setting the property MiniProfiler.Settings.MaxJsonResponseSize to the desired value. By default, this tool seems to ignore the value set in config.



    MiniProfiler.Settings.MaxJsonResponseSize = 104857600;


    Courtesy mvc-mini-profiler.






    share|improve this answer































      7














      Simply set MaxJsonLength proprty in MVC's Action method



      JsonResult json= Json(classObject, JsonRequestBehavior.AllowGet);
      json.MaxJsonLength = int.MaxValue;
      return json;





      share|improve this answer































        6














        I suggest setting it to Int32.MaxValue.



        JavaScriptSerializer serializer = new JavaScriptSerializer();
        serializer.MaxJsonLength = Int32.MaxValue;





        share|improve this answer

































          6














          How about some attribute magic?



          [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
          public class MaxJsonSizeAttribute : ActionFilterAttribute
          {
          // Default: 10 MB worth of one byte chars
          private int maxLength = 10 * 1024 * 1024;

          public int MaxLength
          {
          set
          {
          if (value < 0) throw new ArgumentOutOfRangeException("value", "Value must be at least 0.");

          maxLength = value;
          }
          get { return maxLength; }
          }

          public override void OnActionExecuted(ActionExecutedContext filterContext)
          {
          JsonResult json = filterContext.Result as JsonResult;
          if (json != null)
          {
          if (maxLength == 0)
          {
          json.MaxJsonLength = int.MaxValue;
          }
          else
          {
          json.MaxJsonLength = maxLength;
          }
          }
          }
          }


          Then you could either apply it globally using the global filter configuration or controller/action-wise.






          share|improve this answer


























          • Very good, this work for me.

            – rosta
            Dec 21 '17 at 12:23











          • this did the trick for me. thx.

            – Sikandar Amla
            Feb 13 '18 at 9:38











          • Great answer. Nice use of custom attributes. Wondering if there is a specific (technical) reason that you set the default to 10 MB worth of one byte chars instead of the Max (int.MaxValue)?

            – Josh
            Jan 22 at 21:41











          • @Josh No, there wasn't any special reason for that.

            – Balázs
            Jan 23 at 7:51



















          4














          The question really is whether you really need to return 17k records? How are you planning to handle all the data in the browser? The users are not going to scroll through 17000 rows anyway.



          A better approach is to retrieve only a "top few" records and load more as needed.






          share|improve this answer



















          • 1





            The default list from json will give 17k records. But the autocomplete feature will list only the records that matches the characters that the user types, thus it wont need to scroll the list more. SO what i need is to set unlimited length for maxJsonLength which can serialize the 17k data.

            – Prasad
            Jul 20 '09 at 6:53






          • 6





            You could use a combination of server and client side filtering. It could be hard to filter all the data on the client side, not to mention the network latency.

            – Chetan Sastry
            Jul 20 '09 at 7:17






          • 1





            Having arrived at this same issue a while back, I chose to implement an "onsearch" handler for the autocomplete, and have the web service call pass the "search" text and do a Top10 query using the search criteria as a filter. This meant more individual ajax requests, that just getting the full list on page load, but it also meant that all the requests/responses were much smaller.

            – Mike U
            Dec 11 '15 at 21:21



















          3














          You can set it in the config as others have said, or you can set in on an individual instance of the serializer like:



          var js = new JavaScriptSerializer() { MaxJsonLength = int.MaxValue };





          share|improve this answer































            3














            For those who are having issues with in MVC3 with JSON that's automatically being deserialized for a model binder and is too large, here is a solution.




            1. Copy the code for the JsonValueProviderFactory class from the MVC3 source code into a new class.

            2. Add a line to change the maximum JSON length before the object is deserialized.

            3. Replace the JsonValueProviderFactory class with your new, modified class.


            Thanks to http://blog.naver.com/techshare/100145191355 and https://gist.github.com/DalSoft/1588818 for pointing me in the right direction for how to do this. The last link on the first site contains full source code for the solution.






            share|improve this answer

































              2














              It appears that there is no "unlimited" value. The default is 2097152 characters, which is equivalent to 4 MB of Unicode string data.



              As as already been observed, 17,000 records are hard to use well in the browser. If you are presenting an aggregate view it may be much more efficient to do the aggregation on the server and transfer only a summary in the browser. For example, consider a file system brower, we only see the top of the tree, then emit further requestes as we drill down. The number of records returned in each request is comparatively small. A tree view presentation can work well for large result sets.






              share|improve this answer



















              • 3





                rather bizarrely the default in code (new JavaScriptSerializer()).MaxJsonLength is 2097152 bytes but the web service ResponseFormatJson is the 102400 bytes unless explicitly set.

                – rob
                Jul 24 '14 at 9:56



















              2














              Just ran into this. I'm getting over 6,000 records. Just decided I'd just do some paging. As in, I accept a page number in my MVC JsonResult endpoint, which is defaulted to 0 so it's not necessary, like so:



              public JsonResult MyObjects(int pageNumber = 0)


              Then instead of saying:



              return Json(_repository.MyObjects.ToList(), JsonRequestBehavior.AllowGet);


              I say:



              return Json(_repository.MyObjects.OrderBy(obj => obj.ID).Skip(1000 * pageNumber).Take(1000).ToList(), JsonRequestBehavior.AllowGet);


              It's very simple. Then, in JavaScript, instead of this:



              function myAJAXCallback(items) {
              // Do stuff here
              }


              I instead say:



              var pageNumber = 0;
              function myAJAXCallback(items) {
              if(items.length == 1000)
              // Call same endpoint but add this to the end: '?pageNumber=' + ++pageNumber
              }
              // Do stuff here
              }


              And append your records to whatever you were doing with them in the first place. Or just wait until all the calls finish and cobble the results together.






              share|improve this answer































                2














                I solved the problem adding this code:



                String confString = HttpContext.Current.Request.ApplicationPath.ToString();
                Configuration conf = WebConfigurationManager.OpenWebConfiguration(confString);
                ScriptingJsonSerializationSection section = (ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization");
                section.MaxJsonLength = 6553600;
                conf.Save();





                share|improve this answer
























                • This seems like a hackish solution but interesting approach regardless. I found it useful thanks! For me in apsnet mvc 5 controller I had to remove 'Current' from the namespace. I made a couple adjustments: string confString = HttpContext.Request.ApplicationPath.ToString(); var conf = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(confString); var section = (System.Web.Configuration.ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization"); section.MaxJsonLength = int.MaxValue; conf.Save();

                  – ooXei1sh
                  Mar 19 '16 at 22:54





















                2














                If you are encountering this sort of issue in View, you can use below method to resolve that. Here Iused Newtonsoft package .



                @using Newtonsoft.Json
                <script type="text/javascript">
                var partData = @Html.Raw(JsonConvert.SerializeObject(ViewBag.Part));
                </script>





                share|improve this answer
























                • Does this mean I don't have to worry about max length if I use Json.NET? I don't think there is a way to set max length in Json.NET so I'm hoping it just works out of the box.

                  – kimbaudi
                  Nov 15 '17 at 20:52



















                1














                Alternative ASP.NET MVC 5 Fix:



                (Mine is similar to MFCs answer above with a few small changes)



                I wasn't ready to change to Json.NET just yet and in my case the error was occurring during the request. Best approach in my scenario was modifying the actual JsonValueProviderFactory which applies the fix to the global project and can be done by editing the global.cs file as such.



                JsonValueProviderConfig.Config(ValueProviderFactories.Factories);


                add a web.config entry:



                <add key="aspnet:MaxJsonLength" value="20971520" />


                and then create the two following classes



                public class JsonValueProviderConfig
                {
                public static void Config(ValueProviderFactoryCollection factories)
                {
                var jsonProviderFactory = factories.OfType<JsonValueProviderFactory>().Single();
                factories.Remove(jsonProviderFactory);
                factories.Add(new CustomJsonValueProviderFactory());
                }
                }


                This is basically an exact copy of the default implementation found in System.Web.Mvc but with the addition of a configurable web.config appsetting value aspnet:MaxJsonLength.



                public class CustomJsonValueProviderFactory : ValueProviderFactory
                {

                /// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
                /// <returns>A JSON value-provider object for the specified controller context.</returns>
                /// <param name="controllerContext">The controller context.</param>
                public override IValueProvider GetValueProvider(ControllerContext controllerContext)
                {
                if (controllerContext == null)
                throw new ArgumentNullException("controllerContext");

                object deserializedObject = CustomJsonValueProviderFactory.GetDeserializedObject(controllerContext);
                if (deserializedObject == null)
                return null;

                Dictionary<string, object> strs = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
                CustomJsonValueProviderFactory.AddToBackingStore(new CustomJsonValueProviderFactory.EntryLimitedDictionary(strs), string.Empty, deserializedObject);

                return new DictionaryValueProvider<object>(strs, CultureInfo.CurrentCulture);
                }

                private static object GetDeserializedObject(ControllerContext controllerContext)
                {
                if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                return null;

                string fullStreamString = (new StreamReader(controllerContext.HttpContext.Request.InputStream)).ReadToEnd();
                if (string.IsNullOrEmpty(fullStreamString))
                return null;

                var serializer = new JavaScriptSerializer()
                {
                MaxJsonLength = CustomJsonValueProviderFactory.GetMaxJsonLength()
                };
                return serializer.DeserializeObject(fullStreamString);
                }

                private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
                {
                IDictionary<string, object> strs = value as IDictionary<string, object>;
                if (strs != null)
                {
                foreach (KeyValuePair<string, object> keyValuePair in strs)
                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);

                return;
                }

                IList lists = value as IList;
                if (lists == null)
                {
                backingStore.Add(prefix, value);
                return;
                }

                for (int i = 0; i < lists.Count; i++)
                {
                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakeArrayKey(prefix, i), lists[i]);
                }
                }

                private class EntryLimitedDictionary
                {
                private static int _maximumDepth;

                private readonly IDictionary<string, object> _innerDictionary;

                private int _itemCount;

                static EntryLimitedDictionary()
                {
                _maximumDepth = CustomJsonValueProviderFactory.GetMaximumDepth();
                }

                public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
                {
                this._innerDictionary = innerDictionary;
                }

                public void Add(string key, object value)
                {
                int num = this._itemCount + 1;
                this._itemCount = num;
                if (num > _maximumDepth)
                {
                throw new InvalidOperationException("The length of the string exceeds the value set on the maxJsonLength property.");
                }
                this._innerDictionary.Add(key, value);
                }
                }

                private static string MakeArrayKey(string prefix, int index)
                {
                return string.Concat(prefix, "[", index.ToString(CultureInfo.InvariantCulture), "]");
                }

                private static string MakePropertyKey(string prefix, string propertyName)
                {
                if (string.IsNullOrEmpty(prefix))
                {
                return propertyName;
                }
                return string.Concat(prefix, ".", propertyName);
                }

                private static int GetMaximumDepth()
                {
                int num;
                NameValueCollection appSettings = ConfigurationManager.AppSettings;
                if (appSettings != null)
                {
                string values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
                if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
                {
                return num;
                }
                }
                return 1000;
                }

                private static int GetMaxJsonLength()
                {
                int num;
                NameValueCollection appSettings = ConfigurationManager.AppSettings;
                if (appSettings != null)
                {
                string values = appSettings.GetValues("aspnet:MaxJsonLength");
                if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
                {
                return num;
                }
                }
                return 1000;
                }
                }





                share|improve this answer



















                • 1





                  Thanks it's working ... Thanks a lot @Maxim Gershkovich

                  – Jasper Manickaraj
                  Feb 4 at 10:14



















                0














                use libNewtonsoft.Json.dll



                public string serializeObj(dynamic json) {        
                return JsonConvert.SerializeObject(json);
                }





                share|improve this answer

































                  0














                  Solution for WebForms UpdatePanel:



                  Add a setting to Web.config:



                  <configuration>
                  <appSettings>
                  <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
                  </appSettings>
                  </configuration>


                  https://support.microsoft.com/en-us/kb/981884



                  ScriptRegistrationManager class contains following code:



                  // Serialize the attributes to JSON and write them out
                  JavaScriptSerializer serializer = new JavaScriptSerializer();

                  // Dev10# 877767 - Allow configurable UpdatePanel script block length
                  // The default is JavaScriptSerializer.DefaultMaxJsonLength
                  if (AppSettings.UpdatePanelMaxScriptLength > 0) {
                  serializer.MaxJsonLength = AppSettings.UpdatePanelMaxScriptLength;
                  }

                  string attrText = serializer.Serialize(attrs);





                  share|improve this answer

































                    0














                    We don't need any server side changes. you can fix this only modify by web.config file
                    This helped for me. try this out



                    <appSettings>
                    <add key="aspnet:MaxJsonDeserializerMembers" value="2147483647" />
                    <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
                    </appSettings>

                    and

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







                    share|improve this answer































                      -2














                      if this maxJsonLength value is a int then how big is its int 32bit/64bit/16bit.... i just want to be sure whats the maximum value i can set as my maxJsonLength



                      <scripting>
                      <webServices>
                      <jsonSerialization maxJsonLength="2147483647">
                      </jsonSerialization>
                      </webServices>
                      </scripting>





                      share|improve this answer































                        -2














                        You do not need to do with web.config
                        You can use short property during catch value of the passing list
                        For example
                        declare a model like



                        public class BookModel
                        {
                        public decimal id { get; set; } // 1

                        public string BN { get; set; } // 2 Book Name

                        public string BC { get; set; } // 3 Bar Code Number

                        public string BE { get; set; } // 4 Edition Name

                        public string BAL { get; set; } // 5 Academic Level

                        public string BCAT { get; set; } // 6 Category
                        }


                        here i use short proporties like
                        BC =barcode
                        BE=book edition and so on






                        share|improve this answer
























                        • This won't help if the bulk of the data is in the property values

                          – Window
                          May 31 '18 at 21:44










                        protected by Community Dec 17 '16 at 6:57



                        Thank you for your interest in this question.
                        Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                        Would you like to answer one of these unanswered questions instead?














                        27 Answers
                        27






                        active

                        oldest

                        votes








                        27 Answers
                        27






                        active

                        oldest

                        votes









                        active

                        oldest

                        votes






                        active

                        oldest

                        votes









                        671














                        NOTE: this answer applies only to Web services, if you are returning JSON from a Controller method, make sure you read this SO answer below as well: https://stackoverflow.com/a/7207539/1246870





                        The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k).



                        You can set the MaxJsonLength property on your web.config:



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





                        share|improve this answer





















                        • 145





                          It is an integer so the max value you can set is: 2147483644

                          – David Espart
                          Sep 9 '10 at 10:43






                        • 54





                          @despart: You mean 2 147 483 647.

                          – Dercsár
                          Jul 28 '11 at 11:27






                        • 6





                          @kmcc049, IMO the values aren't wrong because if you look at the question, the OP is not asking "what's the default value of maxJsonLength?" (BTW, the second most voted answer is answering this, wrong question), he's trying to set this property to "unlimited", but since is an Integer, the maximum value possible is 2147483647 as @depsart and @Descár point out.

                          – CMS
                          Sep 23 '11 at 14:49






                        • 11





                          Great but note @David Murdoch's answer below if you're having this problem when using MVC's return Json() or something

                          – BritishDeveloper
                          Mar 13 '12 at 8:55






                        • 2





                          @ Dercsár: whats the point? 2147483644 is the biggest integer perfectly divisible by 1024.

                          – naveen
                          Jun 27 '12 at 10:34
















                        671














                        NOTE: this answer applies only to Web services, if you are returning JSON from a Controller method, make sure you read this SO answer below as well: https://stackoverflow.com/a/7207539/1246870





                        The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k).



                        You can set the MaxJsonLength property on your web.config:



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





                        share|improve this answer





















                        • 145





                          It is an integer so the max value you can set is: 2147483644

                          – David Espart
                          Sep 9 '10 at 10:43






                        • 54





                          @despart: You mean 2 147 483 647.

                          – Dercsár
                          Jul 28 '11 at 11:27






                        • 6





                          @kmcc049, IMO the values aren't wrong because if you look at the question, the OP is not asking "what's the default value of maxJsonLength?" (BTW, the second most voted answer is answering this, wrong question), he's trying to set this property to "unlimited", but since is an Integer, the maximum value possible is 2147483647 as @depsart and @Descár point out.

                          – CMS
                          Sep 23 '11 at 14:49






                        • 11





                          Great but note @David Murdoch's answer below if you're having this problem when using MVC's return Json() or something

                          – BritishDeveloper
                          Mar 13 '12 at 8:55






                        • 2





                          @ Dercsár: whats the point? 2147483644 is the biggest integer perfectly divisible by 1024.

                          – naveen
                          Jun 27 '12 at 10:34














                        671












                        671








                        671







                        NOTE: this answer applies only to Web services, if you are returning JSON from a Controller method, make sure you read this SO answer below as well: https://stackoverflow.com/a/7207539/1246870





                        The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k).



                        You can set the MaxJsonLength property on your web.config:



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





                        share|improve this answer















                        NOTE: this answer applies only to Web services, if you are returning JSON from a Controller method, make sure you read this SO answer below as well: https://stackoverflow.com/a/7207539/1246870





                        The MaxJsonLength property cannot be unlimited, is an integer property that defaults to 102400 (100k).



                        You can set the MaxJsonLength property on your web.config:



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






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited May 23 '17 at 11:55









                        Community

                        11




                        11










                        answered Jul 20 '09 at 6:43









                        CMSCMS

                        605k163848817




                        605k163848817








                        • 145





                          It is an integer so the max value you can set is: 2147483644

                          – David Espart
                          Sep 9 '10 at 10:43






                        • 54





                          @despart: You mean 2 147 483 647.

                          – Dercsár
                          Jul 28 '11 at 11:27






                        • 6





                          @kmcc049, IMO the values aren't wrong because if you look at the question, the OP is not asking "what's the default value of maxJsonLength?" (BTW, the second most voted answer is answering this, wrong question), he's trying to set this property to "unlimited", but since is an Integer, the maximum value possible is 2147483647 as @depsart and @Descár point out.

                          – CMS
                          Sep 23 '11 at 14:49






                        • 11





                          Great but note @David Murdoch's answer below if you're having this problem when using MVC's return Json() or something

                          – BritishDeveloper
                          Mar 13 '12 at 8:55






                        • 2





                          @ Dercsár: whats the point? 2147483644 is the biggest integer perfectly divisible by 1024.

                          – naveen
                          Jun 27 '12 at 10:34














                        • 145





                          It is an integer so the max value you can set is: 2147483644

                          – David Espart
                          Sep 9 '10 at 10:43






                        • 54





                          @despart: You mean 2 147 483 647.

                          – Dercsár
                          Jul 28 '11 at 11:27






                        • 6





                          @kmcc049, IMO the values aren't wrong because if you look at the question, the OP is not asking "what's the default value of maxJsonLength?" (BTW, the second most voted answer is answering this, wrong question), he's trying to set this property to "unlimited", but since is an Integer, the maximum value possible is 2147483647 as @depsart and @Descár point out.

                          – CMS
                          Sep 23 '11 at 14:49






                        • 11





                          Great but note @David Murdoch's answer below if you're having this problem when using MVC's return Json() or something

                          – BritishDeveloper
                          Mar 13 '12 at 8:55






                        • 2





                          @ Dercsár: whats the point? 2147483644 is the biggest integer perfectly divisible by 1024.

                          – naveen
                          Jun 27 '12 at 10:34








                        145




                        145





                        It is an integer so the max value you can set is: 2147483644

                        – David Espart
                        Sep 9 '10 at 10:43





                        It is an integer so the max value you can set is: 2147483644

                        – David Espart
                        Sep 9 '10 at 10:43




                        54




                        54





                        @despart: You mean 2 147 483 647.

                        – Dercsár
                        Jul 28 '11 at 11:27





                        @despart: You mean 2 147 483 647.

                        – Dercsár
                        Jul 28 '11 at 11:27




                        6




                        6





                        @kmcc049, IMO the values aren't wrong because if you look at the question, the OP is not asking "what's the default value of maxJsonLength?" (BTW, the second most voted answer is answering this, wrong question), he's trying to set this property to "unlimited", but since is an Integer, the maximum value possible is 2147483647 as @depsart and @Descár point out.

                        – CMS
                        Sep 23 '11 at 14:49





                        @kmcc049, IMO the values aren't wrong because if you look at the question, the OP is not asking "what's the default value of maxJsonLength?" (BTW, the second most voted answer is answering this, wrong question), he's trying to set this property to "unlimited", but since is an Integer, the maximum value possible is 2147483647 as @depsart and @Descár point out.

                        – CMS
                        Sep 23 '11 at 14:49




                        11




                        11





                        Great but note @David Murdoch's answer below if you're having this problem when using MVC's return Json() or something

                        – BritishDeveloper
                        Mar 13 '12 at 8:55





                        Great but note @David Murdoch's answer below if you're having this problem when using MVC's return Json() or something

                        – BritishDeveloper
                        Mar 13 '12 at 8:55




                        2




                        2





                        @ Dercsár: whats the point? 2147483644 is the biggest integer perfectly divisible by 1024.

                        – naveen
                        Jun 27 '12 at 10:34





                        @ Dercsár: whats the point? 2147483644 is the biggest integer perfectly divisible by 1024.

                        – naveen
                        Jun 27 '12 at 10:34













                        427














                        If you are using MVC 4, be sure to check out this answer as well.





                        If you are still receiving the error:




                        • after setting the maxJsonLength property to its maximum value in web.config

                        • and you know that your data's length is less than this value

                        • and you are not utilizing a web service method for the JavaScript serialization


                        your problem is is likely that:




                        The value of the MaxJsonLength property applies only to the internal JavaScriptSerializer instance that is used by the asynchronous communication layer to invoke Web services methods. (MSDN: ScriptingJsonSerializationSection.MaxJsonLength Property)




                        Basically, the "internal" JavaScriptSerializer respects the value of maxJsonLength when called from a web method; direct use of a JavaScriptSerializer (or use via an MVC action-method/Controller) does not respect the maxJsonLength property, at least not from the systemWebExtensions.scripting.webServices.jsonSerialization section of web.config.



                        As a workaround, you can do the following within your Controller (or anywhere really):



                        var serializer = new JavaScriptSerializer();

                        // For simplicity just use Int32's max value.
                        // You could always read the value from the config section mentioned above.
                        serializer.MaxJsonLength = Int32.MaxValue;

                        var resultData = new { Value = "foo", Text = "var" };
                        var result = new ContentResult{
                        Content = serializer.Serialize(resultData),
                        ContentType = "application/json"
                        };
                        return result;




                        This answer is my interpretation of this asp.net forum answer.






                        share|improve this answer





















                        • 5





                          Your answer was really helpful as I am using the Json() action result method in asp.net mvc.

                          – jessegavin
                          Jan 9 '12 at 15:58






                        • 3





                          Yep I was a Json() suffer too. Thanks!

                          – BritishDeveloper
                          Mar 13 '12 at 8:54






                        • 3





                          Although it is completely correct and deserving of its place, this is one of those questions where it's worth reading past the top answer :). Thanks!

                          – Nigel
                          Apr 19 '12 at 8:14






                        • 3





                          If you're using MVC4 please see @fanisch answer as well.

                          – Beyers
                          Jan 11 '13 at 10:44






                        • 3





                          How about Deserialization? I met this error at action's model binding.

                          – guogangj
                          May 17 '17 at 11:45
















                        427














                        If you are using MVC 4, be sure to check out this answer as well.





                        If you are still receiving the error:




                        • after setting the maxJsonLength property to its maximum value in web.config

                        • and you know that your data's length is less than this value

                        • and you are not utilizing a web service method for the JavaScript serialization


                        your problem is is likely that:




                        The value of the MaxJsonLength property applies only to the internal JavaScriptSerializer instance that is used by the asynchronous communication layer to invoke Web services methods. (MSDN: ScriptingJsonSerializationSection.MaxJsonLength Property)




                        Basically, the "internal" JavaScriptSerializer respects the value of maxJsonLength when called from a web method; direct use of a JavaScriptSerializer (or use via an MVC action-method/Controller) does not respect the maxJsonLength property, at least not from the systemWebExtensions.scripting.webServices.jsonSerialization section of web.config.



                        As a workaround, you can do the following within your Controller (or anywhere really):



                        var serializer = new JavaScriptSerializer();

                        // For simplicity just use Int32's max value.
                        // You could always read the value from the config section mentioned above.
                        serializer.MaxJsonLength = Int32.MaxValue;

                        var resultData = new { Value = "foo", Text = "var" };
                        var result = new ContentResult{
                        Content = serializer.Serialize(resultData),
                        ContentType = "application/json"
                        };
                        return result;




                        This answer is my interpretation of this asp.net forum answer.






                        share|improve this answer





















                        • 5





                          Your answer was really helpful as I am using the Json() action result method in asp.net mvc.

                          – jessegavin
                          Jan 9 '12 at 15:58






                        • 3





                          Yep I was a Json() suffer too. Thanks!

                          – BritishDeveloper
                          Mar 13 '12 at 8:54






                        • 3





                          Although it is completely correct and deserving of its place, this is one of those questions where it's worth reading past the top answer :). Thanks!

                          – Nigel
                          Apr 19 '12 at 8:14






                        • 3





                          If you're using MVC4 please see @fanisch answer as well.

                          – Beyers
                          Jan 11 '13 at 10:44






                        • 3





                          How about Deserialization? I met this error at action's model binding.

                          – guogangj
                          May 17 '17 at 11:45














                        427












                        427








                        427







                        If you are using MVC 4, be sure to check out this answer as well.





                        If you are still receiving the error:




                        • after setting the maxJsonLength property to its maximum value in web.config

                        • and you know that your data's length is less than this value

                        • and you are not utilizing a web service method for the JavaScript serialization


                        your problem is is likely that:




                        The value of the MaxJsonLength property applies only to the internal JavaScriptSerializer instance that is used by the asynchronous communication layer to invoke Web services methods. (MSDN: ScriptingJsonSerializationSection.MaxJsonLength Property)




                        Basically, the "internal" JavaScriptSerializer respects the value of maxJsonLength when called from a web method; direct use of a JavaScriptSerializer (or use via an MVC action-method/Controller) does not respect the maxJsonLength property, at least not from the systemWebExtensions.scripting.webServices.jsonSerialization section of web.config.



                        As a workaround, you can do the following within your Controller (or anywhere really):



                        var serializer = new JavaScriptSerializer();

                        // For simplicity just use Int32's max value.
                        // You could always read the value from the config section mentioned above.
                        serializer.MaxJsonLength = Int32.MaxValue;

                        var resultData = new { Value = "foo", Text = "var" };
                        var result = new ContentResult{
                        Content = serializer.Serialize(resultData),
                        ContentType = "application/json"
                        };
                        return result;




                        This answer is my interpretation of this asp.net forum answer.






                        share|improve this answer















                        If you are using MVC 4, be sure to check out this answer as well.





                        If you are still receiving the error:




                        • after setting the maxJsonLength property to its maximum value in web.config

                        • and you know that your data's length is less than this value

                        • and you are not utilizing a web service method for the JavaScript serialization


                        your problem is is likely that:




                        The value of the MaxJsonLength property applies only to the internal JavaScriptSerializer instance that is used by the asynchronous communication layer to invoke Web services methods. (MSDN: ScriptingJsonSerializationSection.MaxJsonLength Property)




                        Basically, the "internal" JavaScriptSerializer respects the value of maxJsonLength when called from a web method; direct use of a JavaScriptSerializer (or use via an MVC action-method/Controller) does not respect the maxJsonLength property, at least not from the systemWebExtensions.scripting.webServices.jsonSerialization section of web.config.



                        As a workaround, you can do the following within your Controller (or anywhere really):



                        var serializer = new JavaScriptSerializer();

                        // For simplicity just use Int32's max value.
                        // You could always read the value from the config section mentioned above.
                        serializer.MaxJsonLength = Int32.MaxValue;

                        var resultData = new { Value = "foo", Text = "var" };
                        var result = new ContentResult{
                        Content = serializer.Serialize(resultData),
                        ContentType = "application/json"
                        };
                        return result;




                        This answer is my interpretation of this asp.net forum answer.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited May 23 '17 at 12:26









                        Community

                        11




                        11










                        answered Aug 26 '11 at 16:04









                        David MurdochDavid Murdoch

                        57.6k37131177




                        57.6k37131177








                        • 5





                          Your answer was really helpful as I am using the Json() action result method in asp.net mvc.

                          – jessegavin
                          Jan 9 '12 at 15:58






                        • 3





                          Yep I was a Json() suffer too. Thanks!

                          – BritishDeveloper
                          Mar 13 '12 at 8:54






                        • 3





                          Although it is completely correct and deserving of its place, this is one of those questions where it's worth reading past the top answer :). Thanks!

                          – Nigel
                          Apr 19 '12 at 8:14






                        • 3





                          If you're using MVC4 please see @fanisch answer as well.

                          – Beyers
                          Jan 11 '13 at 10:44






                        • 3





                          How about Deserialization? I met this error at action's model binding.

                          – guogangj
                          May 17 '17 at 11:45














                        • 5





                          Your answer was really helpful as I am using the Json() action result method in asp.net mvc.

                          – jessegavin
                          Jan 9 '12 at 15:58






                        • 3





                          Yep I was a Json() suffer too. Thanks!

                          – BritishDeveloper
                          Mar 13 '12 at 8:54






                        • 3





                          Although it is completely correct and deserving of its place, this is one of those questions where it's worth reading past the top answer :). Thanks!

                          – Nigel
                          Apr 19 '12 at 8:14






                        • 3





                          If you're using MVC4 please see @fanisch answer as well.

                          – Beyers
                          Jan 11 '13 at 10:44






                        • 3





                          How about Deserialization? I met this error at action's model binding.

                          – guogangj
                          May 17 '17 at 11:45








                        5




                        5





                        Your answer was really helpful as I am using the Json() action result method in asp.net mvc.

                        – jessegavin
                        Jan 9 '12 at 15:58





                        Your answer was really helpful as I am using the Json() action result method in asp.net mvc.

                        – jessegavin
                        Jan 9 '12 at 15:58




                        3




                        3





                        Yep I was a Json() suffer too. Thanks!

                        – BritishDeveloper
                        Mar 13 '12 at 8:54





                        Yep I was a Json() suffer too. Thanks!

                        – BritishDeveloper
                        Mar 13 '12 at 8:54




                        3




                        3





                        Although it is completely correct and deserving of its place, this is one of those questions where it's worth reading past the top answer :). Thanks!

                        – Nigel
                        Apr 19 '12 at 8:14





                        Although it is completely correct and deserving of its place, this is one of those questions where it's worth reading past the top answer :). Thanks!

                        – Nigel
                        Apr 19 '12 at 8:14




                        3




                        3





                        If you're using MVC4 please see @fanisch answer as well.

                        – Beyers
                        Jan 11 '13 at 10:44





                        If you're using MVC4 please see @fanisch answer as well.

                        – Beyers
                        Jan 11 '13 at 10:44




                        3




                        3





                        How about Deserialization? I met this error at action's model binding.

                        – guogangj
                        May 17 '17 at 11:45





                        How about Deserialization? I met this error at action's model binding.

                        – guogangj
                        May 17 '17 at 11:45











                        312














                        In MVC 4 you can do:



                        protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
                        {
                        return new JsonResult()
                        {
                        Data = data,
                        ContentType = contentType,
                        ContentEncoding = contentEncoding,
                        JsonRequestBehavior = behavior,
                        MaxJsonLength = Int32.MaxValue
                        };
                        }


                        in your controller.



                        Addition:



                        For anyone puzzled by the parameters you need to specify, a call could look like this:



                        Json(
                        new {
                        field1 = true,
                        field2 = "value"
                        },
                        "application/json",
                        Encoding.UTF8,
                        JsonRequestBehavior.AllowGet
                        );





                        share|improve this answer





















                        • 6





                          I can confirm that the above works like a charm in MVC 4, thank you fanisch.

                          – Beyers
                          Jan 11 '13 at 10:42






                        • 9





                          I can confirm as well. Putting this code inside a base controller is definitely the cleanest approach proposed.

                          – parliament
                          Mar 5 '13 at 9:13






                        • 12





                          This also works by just adding "MaxJsonLength = Int32.MaxValue" to the individual action result. In case the change is not desired controller or project wide.

                          – Hypnovirus
                          Apr 18 '13 at 2:57








                        • 3





                          This is the best answer. The MaxJsonLength can be configured per controller.

                          – liang
                          Sep 7 '14 at 10:32






                        • 3





                          WARNING: this solution disables the compression (if requested) of the response. Add this filter on your action: stackoverflow.com/questions/3802107/…

                          – Gorgi Rankovski
                          Dec 22 '15 at 14:55


















                        312














                        In MVC 4 you can do:



                        protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
                        {
                        return new JsonResult()
                        {
                        Data = data,
                        ContentType = contentType,
                        ContentEncoding = contentEncoding,
                        JsonRequestBehavior = behavior,
                        MaxJsonLength = Int32.MaxValue
                        };
                        }


                        in your controller.



                        Addition:



                        For anyone puzzled by the parameters you need to specify, a call could look like this:



                        Json(
                        new {
                        field1 = true,
                        field2 = "value"
                        },
                        "application/json",
                        Encoding.UTF8,
                        JsonRequestBehavior.AllowGet
                        );





                        share|improve this answer





















                        • 6





                          I can confirm that the above works like a charm in MVC 4, thank you fanisch.

                          – Beyers
                          Jan 11 '13 at 10:42






                        • 9





                          I can confirm as well. Putting this code inside a base controller is definitely the cleanest approach proposed.

                          – parliament
                          Mar 5 '13 at 9:13






                        • 12





                          This also works by just adding "MaxJsonLength = Int32.MaxValue" to the individual action result. In case the change is not desired controller or project wide.

                          – Hypnovirus
                          Apr 18 '13 at 2:57








                        • 3





                          This is the best answer. The MaxJsonLength can be configured per controller.

                          – liang
                          Sep 7 '14 at 10:32






                        • 3





                          WARNING: this solution disables the compression (if requested) of the response. Add this filter on your action: stackoverflow.com/questions/3802107/…

                          – Gorgi Rankovski
                          Dec 22 '15 at 14:55
















                        312












                        312








                        312







                        In MVC 4 you can do:



                        protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
                        {
                        return new JsonResult()
                        {
                        Data = data,
                        ContentType = contentType,
                        ContentEncoding = contentEncoding,
                        JsonRequestBehavior = behavior,
                        MaxJsonLength = Int32.MaxValue
                        };
                        }


                        in your controller.



                        Addition:



                        For anyone puzzled by the parameters you need to specify, a call could look like this:



                        Json(
                        new {
                        field1 = true,
                        field2 = "value"
                        },
                        "application/json",
                        Encoding.UTF8,
                        JsonRequestBehavior.AllowGet
                        );





                        share|improve this answer















                        In MVC 4 you can do:



                        protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
                        {
                        return new JsonResult()
                        {
                        Data = data,
                        ContentType = contentType,
                        ContentEncoding = contentEncoding,
                        JsonRequestBehavior = behavior,
                        MaxJsonLength = Int32.MaxValue
                        };
                        }


                        in your controller.



                        Addition:



                        For anyone puzzled by the parameters you need to specify, a call could look like this:



                        Json(
                        new {
                        field1 = true,
                        field2 = "value"
                        },
                        "application/json",
                        Encoding.UTF8,
                        JsonRequestBehavior.AllowGet
                        );






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Aug 17 '18 at 12:51









                        R. Schreurs

                        3,81732943




                        3,81732943










                        answered Sep 5 '12 at 10:03









                        fanischfanisch

                        3,2231910




                        3,2231910








                        • 6





                          I can confirm that the above works like a charm in MVC 4, thank you fanisch.

                          – Beyers
                          Jan 11 '13 at 10:42






                        • 9





                          I can confirm as well. Putting this code inside a base controller is definitely the cleanest approach proposed.

                          – parliament
                          Mar 5 '13 at 9:13






                        • 12





                          This also works by just adding "MaxJsonLength = Int32.MaxValue" to the individual action result. In case the change is not desired controller or project wide.

                          – Hypnovirus
                          Apr 18 '13 at 2:57








                        • 3





                          This is the best answer. The MaxJsonLength can be configured per controller.

                          – liang
                          Sep 7 '14 at 10:32






                        • 3





                          WARNING: this solution disables the compression (if requested) of the response. Add this filter on your action: stackoverflow.com/questions/3802107/…

                          – Gorgi Rankovski
                          Dec 22 '15 at 14:55
















                        • 6





                          I can confirm that the above works like a charm in MVC 4, thank you fanisch.

                          – Beyers
                          Jan 11 '13 at 10:42






                        • 9





                          I can confirm as well. Putting this code inside a base controller is definitely the cleanest approach proposed.

                          – parliament
                          Mar 5 '13 at 9:13






                        • 12





                          This also works by just adding "MaxJsonLength = Int32.MaxValue" to the individual action result. In case the change is not desired controller or project wide.

                          – Hypnovirus
                          Apr 18 '13 at 2:57








                        • 3





                          This is the best answer. The MaxJsonLength can be configured per controller.

                          – liang
                          Sep 7 '14 at 10:32






                        • 3





                          WARNING: this solution disables the compression (if requested) of the response. Add this filter on your action: stackoverflow.com/questions/3802107/…

                          – Gorgi Rankovski
                          Dec 22 '15 at 14:55










                        6




                        6





                        I can confirm that the above works like a charm in MVC 4, thank you fanisch.

                        – Beyers
                        Jan 11 '13 at 10:42





                        I can confirm that the above works like a charm in MVC 4, thank you fanisch.

                        – Beyers
                        Jan 11 '13 at 10:42




                        9




                        9





                        I can confirm as well. Putting this code inside a base controller is definitely the cleanest approach proposed.

                        – parliament
                        Mar 5 '13 at 9:13





                        I can confirm as well. Putting this code inside a base controller is definitely the cleanest approach proposed.

                        – parliament
                        Mar 5 '13 at 9:13




                        12




                        12





                        This also works by just adding "MaxJsonLength = Int32.MaxValue" to the individual action result. In case the change is not desired controller or project wide.

                        – Hypnovirus
                        Apr 18 '13 at 2:57







                        This also works by just adding "MaxJsonLength = Int32.MaxValue" to the individual action result. In case the change is not desired controller or project wide.

                        – Hypnovirus
                        Apr 18 '13 at 2:57






                        3




                        3





                        This is the best answer. The MaxJsonLength can be configured per controller.

                        – liang
                        Sep 7 '14 at 10:32





                        This is the best answer. The MaxJsonLength can be configured per controller.

                        – liang
                        Sep 7 '14 at 10:32




                        3




                        3





                        WARNING: this solution disables the compression (if requested) of the response. Add this filter on your action: stackoverflow.com/questions/3802107/…

                        – Gorgi Rankovski
                        Dec 22 '15 at 14:55







                        WARNING: this solution disables the compression (if requested) of the response. Add this filter on your action: stackoverflow.com/questions/3802107/…

                        – Gorgi Rankovski
                        Dec 22 '15 at 14:55













                        58














                        You can configure the max length for json requests in your web.config file:



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


                        The default value for maxJsonLength is 102400. For more details, see this MSDN page: http://msdn.microsoft.com/en-us/library/bb763183.aspx






                        share|improve this answer





















                        • 1





                          What is the stored value in this integer representing? Is this some sort of count of character? I guess what I am asking is, why an integer is being used? Thanks!

                          – eaglei22
                          Mar 20 '17 at 12:21











                        • @eaglei22 the number represents how many bytes can be used for the maxJsonLength. As M4N mentioned, 102400 is the default (100KB).

                          – Jacob Plonke
                          Jul 11 '17 at 12:25











                        • this is not worked for me and i not used webservices.

                          – kalai
                          Mar 28 at 8:45
















                        58














                        You can configure the max length for json requests in your web.config file:



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


                        The default value for maxJsonLength is 102400. For more details, see this MSDN page: http://msdn.microsoft.com/en-us/library/bb763183.aspx






                        share|improve this answer





















                        • 1





                          What is the stored value in this integer representing? Is this some sort of count of character? I guess what I am asking is, why an integer is being used? Thanks!

                          – eaglei22
                          Mar 20 '17 at 12:21











                        • @eaglei22 the number represents how many bytes can be used for the maxJsonLength. As M4N mentioned, 102400 is the default (100KB).

                          – Jacob Plonke
                          Jul 11 '17 at 12:25











                        • this is not worked for me and i not used webservices.

                          – kalai
                          Mar 28 at 8:45














                        58












                        58








                        58







                        You can configure the max length for json requests in your web.config file:



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


                        The default value for maxJsonLength is 102400. For more details, see this MSDN page: http://msdn.microsoft.com/en-us/library/bb763183.aspx






                        share|improve this answer















                        You can configure the max length for json requests in your web.config file:



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


                        The default value for maxJsonLength is 102400. For more details, see this MSDN page: http://msdn.microsoft.com/en-us/library/bb763183.aspx







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Aug 28 '10 at 3:48









                        Ian Boyd

                        123k1926971017




                        123k1926971017










                        answered Jul 20 '09 at 6:43









                        M4NM4N

                        75.5k40192249




                        75.5k40192249








                        • 1





                          What is the stored value in this integer representing? Is this some sort of count of character? I guess what I am asking is, why an integer is being used? Thanks!

                          – eaglei22
                          Mar 20 '17 at 12:21











                        • @eaglei22 the number represents how many bytes can be used for the maxJsonLength. As M4N mentioned, 102400 is the default (100KB).

                          – Jacob Plonke
                          Jul 11 '17 at 12:25











                        • this is not worked for me and i not used webservices.

                          – kalai
                          Mar 28 at 8:45














                        • 1





                          What is the stored value in this integer representing? Is this some sort of count of character? I guess what I am asking is, why an integer is being used? Thanks!

                          – eaglei22
                          Mar 20 '17 at 12:21











                        • @eaglei22 the number represents how many bytes can be used for the maxJsonLength. As M4N mentioned, 102400 is the default (100KB).

                          – Jacob Plonke
                          Jul 11 '17 at 12:25











                        • this is not worked for me and i not used webservices.

                          – kalai
                          Mar 28 at 8:45








                        1




                        1





                        What is the stored value in this integer representing? Is this some sort of count of character? I guess what I am asking is, why an integer is being used? Thanks!

                        – eaglei22
                        Mar 20 '17 at 12:21





                        What is the stored value in this integer representing? Is this some sort of count of character? I guess what I am asking is, why an integer is being used? Thanks!

                        – eaglei22
                        Mar 20 '17 at 12:21













                        @eaglei22 the number represents how many bytes can be used for the maxJsonLength. As M4N mentioned, 102400 is the default (100KB).

                        – Jacob Plonke
                        Jul 11 '17 at 12:25





                        @eaglei22 the number represents how many bytes can be used for the maxJsonLength. As M4N mentioned, 102400 is the default (100KB).

                        – Jacob Plonke
                        Jul 11 '17 at 12:25













                        this is not worked for me and i not used webservices.

                        – kalai
                        Mar 28 at 8:45





                        this is not worked for me and i not used webservices.

                        – kalai
                        Mar 28 at 8:45











                        33














                        I was having this problem in ASP.NET Web Forms. It was completely ignoring the web.config file settings so I did this:



                                JavaScriptSerializer serializer = new JavaScriptSerializer();

                        serializer.MaxJsonLength = Int32.MaxValue;

                        return serializer.Serialize(response);


                        Of course overall this is terrible practice. If you are sending this much data in a web service call you should look at a different approach.






                        share|improve this answer





















                        • 1





                          did this work for you? where did you place this code?

                          – user1012598
                          Feb 10 '15 at 6:12











                        • Our problem was because we had a textarea that allowed for HTML and people were embedding images as HTML which caused the entry to become very large and JSON serializer to fail. I guess if it can be done users will do it...

                          – Marko
                          Jul 27 '15 at 15:09











                        • Please describe where we should put this code... @Flea

                          – Koray Durudogan
                          Nov 14 '16 at 12:05











                        • @KorayDurudogan - I put this in the Ajax method that was returning the response, so in my controller. Hope that helps!

                          – Flea
                          Nov 15 '16 at 19:42











                        • I am not challenging your response, but trying to get a better idea of what better approaches there are. I have a query that depending on what the user's criteria is will determine the result size. I return a JsonResult, Would it matter if I returned an excel file?

                          – eaglei22
                          Mar 20 '17 at 12:24
















                        33














                        I was having this problem in ASP.NET Web Forms. It was completely ignoring the web.config file settings so I did this:



                                JavaScriptSerializer serializer = new JavaScriptSerializer();

                        serializer.MaxJsonLength = Int32.MaxValue;

                        return serializer.Serialize(response);


                        Of course overall this is terrible practice. If you are sending this much data in a web service call you should look at a different approach.






                        share|improve this answer





















                        • 1





                          did this work for you? where did you place this code?

                          – user1012598
                          Feb 10 '15 at 6:12











                        • Our problem was because we had a textarea that allowed for HTML and people were embedding images as HTML which caused the entry to become very large and JSON serializer to fail. I guess if it can be done users will do it...

                          – Marko
                          Jul 27 '15 at 15:09











                        • Please describe where we should put this code... @Flea

                          – Koray Durudogan
                          Nov 14 '16 at 12:05











                        • @KorayDurudogan - I put this in the Ajax method that was returning the response, so in my controller. Hope that helps!

                          – Flea
                          Nov 15 '16 at 19:42











                        • I am not challenging your response, but trying to get a better idea of what better approaches there are. I have a query that depending on what the user's criteria is will determine the result size. I return a JsonResult, Would it matter if I returned an excel file?

                          – eaglei22
                          Mar 20 '17 at 12:24














                        33












                        33








                        33







                        I was having this problem in ASP.NET Web Forms. It was completely ignoring the web.config file settings so I did this:



                                JavaScriptSerializer serializer = new JavaScriptSerializer();

                        serializer.MaxJsonLength = Int32.MaxValue;

                        return serializer.Serialize(response);


                        Of course overall this is terrible practice. If you are sending this much data in a web service call you should look at a different approach.






                        share|improve this answer















                        I was having this problem in ASP.NET Web Forms. It was completely ignoring the web.config file settings so I did this:



                                JavaScriptSerializer serializer = new JavaScriptSerializer();

                        serializer.MaxJsonLength = Int32.MaxValue;

                        return serializer.Serialize(response);


                        Of course overall this is terrible practice. If you are sending this much data in a web service call you should look at a different approach.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Feb 10 '15 at 15:46

























                        answered Aug 20 '14 at 19:34









                        FleaFlea

                        8,98856168




                        8,98856168








                        • 1





                          did this work for you? where did you place this code?

                          – user1012598
                          Feb 10 '15 at 6:12











                        • Our problem was because we had a textarea that allowed for HTML and people were embedding images as HTML which caused the entry to become very large and JSON serializer to fail. I guess if it can be done users will do it...

                          – Marko
                          Jul 27 '15 at 15:09











                        • Please describe where we should put this code... @Flea

                          – Koray Durudogan
                          Nov 14 '16 at 12:05











                        • @KorayDurudogan - I put this in the Ajax method that was returning the response, so in my controller. Hope that helps!

                          – Flea
                          Nov 15 '16 at 19:42











                        • I am not challenging your response, but trying to get a better idea of what better approaches there are. I have a query that depending on what the user's criteria is will determine the result size. I return a JsonResult, Would it matter if I returned an excel file?

                          – eaglei22
                          Mar 20 '17 at 12:24














                        • 1





                          did this work for you? where did you place this code?

                          – user1012598
                          Feb 10 '15 at 6:12











                        • Our problem was because we had a textarea that allowed for HTML and people were embedding images as HTML which caused the entry to become very large and JSON serializer to fail. I guess if it can be done users will do it...

                          – Marko
                          Jul 27 '15 at 15:09











                        • Please describe where we should put this code... @Flea

                          – Koray Durudogan
                          Nov 14 '16 at 12:05











                        • @KorayDurudogan - I put this in the Ajax method that was returning the response, so in my controller. Hope that helps!

                          – Flea
                          Nov 15 '16 at 19:42











                        • I am not challenging your response, but trying to get a better idea of what better approaches there are. I have a query that depending on what the user's criteria is will determine the result size. I return a JsonResult, Would it matter if I returned an excel file?

                          – eaglei22
                          Mar 20 '17 at 12:24








                        1




                        1





                        did this work for you? where did you place this code?

                        – user1012598
                        Feb 10 '15 at 6:12





                        did this work for you? where did you place this code?

                        – user1012598
                        Feb 10 '15 at 6:12













                        Our problem was because we had a textarea that allowed for HTML and people were embedding images as HTML which caused the entry to become very large and JSON serializer to fail. I guess if it can be done users will do it...

                        – Marko
                        Jul 27 '15 at 15:09





                        Our problem was because we had a textarea that allowed for HTML and people were embedding images as HTML which caused the entry to become very large and JSON serializer to fail. I guess if it can be done users will do it...

                        – Marko
                        Jul 27 '15 at 15:09













                        Please describe where we should put this code... @Flea

                        – Koray Durudogan
                        Nov 14 '16 at 12:05





                        Please describe where we should put this code... @Flea

                        – Koray Durudogan
                        Nov 14 '16 at 12:05













                        @KorayDurudogan - I put this in the Ajax method that was returning the response, so in my controller. Hope that helps!

                        – Flea
                        Nov 15 '16 at 19:42





                        @KorayDurudogan - I put this in the Ajax method that was returning the response, so in my controller. Hope that helps!

                        – Flea
                        Nov 15 '16 at 19:42













                        I am not challenging your response, but trying to get a better idea of what better approaches there are. I have a query that depending on what the user's criteria is will determine the result size. I return a JsonResult, Would it matter if I returned an excel file?

                        – eaglei22
                        Mar 20 '17 at 12:24





                        I am not challenging your response, but trying to get a better idea of what better approaches there are. I have a query that depending on what the user's criteria is will determine the result size. I return a JsonResult, Would it matter if I returned an excel file?

                        – eaglei22
                        Mar 20 '17 at 12:24











                        26














                        if you are still getting error after web.config setting like following:




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





                        I solved it by following:



                           public ActionResult/JsonResult getData()
                        {
                        var jsonResult = Json(superlargedata, JsonRequestBehavior.AllowGet);
                        jsonResult.MaxJsonLength = int.MaxValue;
                        return jsonResult;
                        }


                        I hope this should help.






                        share|improve this answer


























                        • Setting the maxJsonLength in the web.config is unnesseary, setting the jsonResult.MaxJsonLength should suffice (at least it did for me (MVC5))

                          – hormberg
                          May 18 '18 at 7:45
















                        26














                        if you are still getting error after web.config setting like following:




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





                        I solved it by following:



                           public ActionResult/JsonResult getData()
                        {
                        var jsonResult = Json(superlargedata, JsonRequestBehavior.AllowGet);
                        jsonResult.MaxJsonLength = int.MaxValue;
                        return jsonResult;
                        }


                        I hope this should help.






                        share|improve this answer


























                        • Setting the maxJsonLength in the web.config is unnesseary, setting the jsonResult.MaxJsonLength should suffice (at least it did for me (MVC5))

                          – hormberg
                          May 18 '18 at 7:45














                        26












                        26








                        26







                        if you are still getting error after web.config setting like following:




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





                        I solved it by following:



                           public ActionResult/JsonResult getData()
                        {
                        var jsonResult = Json(superlargedata, JsonRequestBehavior.AllowGet);
                        jsonResult.MaxJsonLength = int.MaxValue;
                        return jsonResult;
                        }


                        I hope this should help.






                        share|improve this answer















                        if you are still getting error after web.config setting like following:




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





                        I solved it by following:



                           public ActionResult/JsonResult getData()
                        {
                        var jsonResult = Json(superlargedata, JsonRequestBehavior.AllowGet);
                        jsonResult.MaxJsonLength = int.MaxValue;
                        return jsonResult;
                        }


                        I hope this should help.






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





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






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Mar 16 '18 at 21:54

























                        answered Sep 19 '16 at 9:44









                        Ravi AnandRavi Anand

                        1,52922038




                        1,52922038













                        • Setting the maxJsonLength in the web.config is unnesseary, setting the jsonResult.MaxJsonLength should suffice (at least it did for me (MVC5))

                          – hormberg
                          May 18 '18 at 7:45



















                        • Setting the maxJsonLength in the web.config is unnesseary, setting the jsonResult.MaxJsonLength should suffice (at least it did for me (MVC5))

                          – hormberg
                          May 18 '18 at 7:45

















                        Setting the maxJsonLength in the web.config is unnesseary, setting the jsonResult.MaxJsonLength should suffice (at least it did for me (MVC5))

                        – hormberg
                        May 18 '18 at 7:45





                        Setting the maxJsonLength in the web.config is unnesseary, setting the jsonResult.MaxJsonLength should suffice (at least it did for me (MVC5))

                        – hormberg
                        May 18 '18 at 7:45











                        21














                        I fixed it.



                        //your Json data here
                        string json_object="........";
                        JavaScriptSerializer jsJson = new JavaScriptSerializer();
                        jsJson.MaxJsonLength = 2147483644;
                        MyClass obj = jsJson.Deserialize<MyClass>(json_object);


                        It works very well.






                        share|improve this answer


























                        • Awesome! This is the only solution that worked for me and its better anyways since its not a global change. Thanks!

                          – Sealer_05
                          Nov 6 '15 at 19:41


















                        21














                        I fixed it.



                        //your Json data here
                        string json_object="........";
                        JavaScriptSerializer jsJson = new JavaScriptSerializer();
                        jsJson.MaxJsonLength = 2147483644;
                        MyClass obj = jsJson.Deserialize<MyClass>(json_object);


                        It works very well.






                        share|improve this answer


























                        • Awesome! This is the only solution that worked for me and its better anyways since its not a global change. Thanks!

                          – Sealer_05
                          Nov 6 '15 at 19:41
















                        21












                        21








                        21







                        I fixed it.



                        //your Json data here
                        string json_object="........";
                        JavaScriptSerializer jsJson = new JavaScriptSerializer();
                        jsJson.MaxJsonLength = 2147483644;
                        MyClass obj = jsJson.Deserialize<MyClass>(json_object);


                        It works very well.






                        share|improve this answer















                        I fixed it.



                        //your Json data here
                        string json_object="........";
                        JavaScriptSerializer jsJson = new JavaScriptSerializer();
                        jsJson.MaxJsonLength = 2147483644;
                        MyClass obj = jsJson.Deserialize<MyClass>(json_object);


                        It works very well.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Nov 9 '12 at 5:01









                        Joseph Quinsey

                        7,188104164




                        7,188104164










                        answered Oct 18 '11 at 13:27









                        Mario ArrietaMario Arrieta

                        21122




                        21122













                        • Awesome! This is the only solution that worked for me and its better anyways since its not a global change. Thanks!

                          – Sealer_05
                          Nov 6 '15 at 19:41





















                        • Awesome! This is the only solution that worked for me and its better anyways since its not a global change. Thanks!

                          – Sealer_05
                          Nov 6 '15 at 19:41



















                        Awesome! This is the only solution that worked for me and its better anyways since its not a global change. Thanks!

                        – Sealer_05
                        Nov 6 '15 at 19:41







                        Awesome! This is the only solution that worked for me and its better anyways since its not a global change. Thanks!

                        – Sealer_05
                        Nov 6 '15 at 19:41













                        16














                        if, after implementing the above addition into your web.config, you get an “Unrecognized configuration section system.web.extensions.” error then try adding this to your web.config in the <ConfigSections> section:



                                    <sectionGroup name="system.web.extensions" type="System.Web.Extensions">
                        <sectionGroup name="scripting" type="System.Web.Extensions">
                        <sectionGroup name="webServices" type="System.Web.Extensions">
                        <section name="jsonSerialization" type="System.Web.Extensions"/>
                        </sectionGroup>
                        </sectionGroup>
                        </sectionGroup>





                        share|improve this answer



















                        • 4





                          I was having this problem. However, this answer did not work for me. Instead of adding the <sectionGroup> element described here, I just moved the whole newly added <system.web.extensions> block to the very end of my web.config... right before </configuration>. Then it worked.

                          – ClearCloud8
                          Nov 2 '12 at 15:09











                        • This helped, but in my situation I needed to change your fourth line to <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>, as seen on this page: forums.asp.net/t/1446510.aspx/1

                          – Nathan
                          Jun 25 '13 at 13:54













                        • @ClearCloud8 Get that comment spread across this page immediately.

                          – Jack Nutkins
                          Jan 25 '16 at 0:04
















                        16














                        if, after implementing the above addition into your web.config, you get an “Unrecognized configuration section system.web.extensions.” error then try adding this to your web.config in the <ConfigSections> section:



                                    <sectionGroup name="system.web.extensions" type="System.Web.Extensions">
                        <sectionGroup name="scripting" type="System.Web.Extensions">
                        <sectionGroup name="webServices" type="System.Web.Extensions">
                        <section name="jsonSerialization" type="System.Web.Extensions"/>
                        </sectionGroup>
                        </sectionGroup>
                        </sectionGroup>





                        share|improve this answer



















                        • 4





                          I was having this problem. However, this answer did not work for me. Instead of adding the <sectionGroup> element described here, I just moved the whole newly added <system.web.extensions> block to the very end of my web.config... right before </configuration>. Then it worked.

                          – ClearCloud8
                          Nov 2 '12 at 15:09











                        • This helped, but in my situation I needed to change your fourth line to <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>, as seen on this page: forums.asp.net/t/1446510.aspx/1

                          – Nathan
                          Jun 25 '13 at 13:54













                        • @ClearCloud8 Get that comment spread across this page immediately.

                          – Jack Nutkins
                          Jan 25 '16 at 0:04














                        16












                        16








                        16







                        if, after implementing the above addition into your web.config, you get an “Unrecognized configuration section system.web.extensions.” error then try adding this to your web.config in the <ConfigSections> section:



                                    <sectionGroup name="system.web.extensions" type="System.Web.Extensions">
                        <sectionGroup name="scripting" type="System.Web.Extensions">
                        <sectionGroup name="webServices" type="System.Web.Extensions">
                        <section name="jsonSerialization" type="System.Web.Extensions"/>
                        </sectionGroup>
                        </sectionGroup>
                        </sectionGroup>





                        share|improve this answer













                        if, after implementing the above addition into your web.config, you get an “Unrecognized configuration section system.web.extensions.” error then try adding this to your web.config in the <ConfigSections> section:



                                    <sectionGroup name="system.web.extensions" type="System.Web.Extensions">
                        <sectionGroup name="scripting" type="System.Web.Extensions">
                        <sectionGroup name="webServices" type="System.Web.Extensions">
                        <section name="jsonSerialization" type="System.Web.Extensions"/>
                        </sectionGroup>
                        </sectionGroup>
                        </sectionGroup>






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jan 12 '11 at 0:17









                        bkdraperbkdraper

                        75965




                        75965








                        • 4





                          I was having this problem. However, this answer did not work for me. Instead of adding the <sectionGroup> element described here, I just moved the whole newly added <system.web.extensions> block to the very end of my web.config... right before </configuration>. Then it worked.

                          – ClearCloud8
                          Nov 2 '12 at 15:09











                        • This helped, but in my situation I needed to change your fourth line to <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>, as seen on this page: forums.asp.net/t/1446510.aspx/1

                          – Nathan
                          Jun 25 '13 at 13:54













                        • @ClearCloud8 Get that comment spread across this page immediately.

                          – Jack Nutkins
                          Jan 25 '16 at 0:04














                        • 4





                          I was having this problem. However, this answer did not work for me. Instead of adding the <sectionGroup> element described here, I just moved the whole newly added <system.web.extensions> block to the very end of my web.config... right before </configuration>. Then it worked.

                          – ClearCloud8
                          Nov 2 '12 at 15:09











                        • This helped, but in my situation I needed to change your fourth line to <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>, as seen on this page: forums.asp.net/t/1446510.aspx/1

                          – Nathan
                          Jun 25 '13 at 13:54













                        • @ClearCloud8 Get that comment spread across this page immediately.

                          – Jack Nutkins
                          Jan 25 '16 at 0:04








                        4




                        4





                        I was having this problem. However, this answer did not work for me. Instead of adding the <sectionGroup> element described here, I just moved the whole newly added <system.web.extensions> block to the very end of my web.config... right before </configuration>. Then it worked.

                        – ClearCloud8
                        Nov 2 '12 at 15:09





                        I was having this problem. However, this answer did not work for me. Instead of adding the <sectionGroup> element described here, I just moved the whole newly added <system.web.extensions> block to the very end of my web.config... right before </configuration>. Then it worked.

                        – ClearCloud8
                        Nov 2 '12 at 15:09













                        This helped, but in my situation I needed to change your fourth line to <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>, as seen on this page: forums.asp.net/t/1446510.aspx/1

                        – Nathan
                        Jun 25 '13 at 13:54







                        This helped, but in my situation I needed to change your fourth line to <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>, as seen on this page: forums.asp.net/t/1446510.aspx/1

                        – Nathan
                        Jun 25 '13 at 13:54















                        @ClearCloud8 Get that comment spread across this page immediately.

                        – Jack Nutkins
                        Jan 25 '16 at 0:04





                        @ClearCloud8 Get that comment spread across this page immediately.

                        – Jack Nutkins
                        Jan 25 '16 at 0:04











                        14





                        +50









                        I followed vestigal's answer and got to this solution:



                        When I needed to post a large json to an action in a controller, I would get the famous "Error during deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.rnParameter name: input value provider".



                        What I did is create a new ValueProviderFactory, LargeJsonValueProviderFactory, and set the MaxJsonLength = Int32.MaxValue in the GetDeserializedObject method



                        public sealed class LargeJsonValueProviderFactory : ValueProviderFactory
                        {
                        private static void AddToBackingStore(LargeJsonValueProviderFactory.EntryLimitedDictionary backingStore, string prefix, object value)
                        {
                        IDictionary<string, object> dictionary = value as IDictionary<string, object>;
                        if (dictionary != null)
                        {
                        foreach (KeyValuePair<string, object> keyValuePair in (IEnumerable<KeyValuePair<string, object>>) dictionary)
                        LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);
                        }
                        else
                        {
                        IList list = value as IList;
                        if (list != null)
                        {
                        for (int index = 0; index < list.Count; ++index)
                        LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakeArrayKey(prefix, index), list[index]);
                        }
                        else
                        backingStore.Add(prefix, value);
                        }
                        }

                        private static object GetDeserializedObject(ControllerContext controllerContext)
                        {
                        if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                        return (object) null;
                        string end = new StreamReader(controllerContext.HttpContext.Request.InputStream).ReadToEnd();
                        if (string.IsNullOrEmpty(end))
                        return (object) null;

                        var serializer = new JavaScriptSerializer {MaxJsonLength = Int32.MaxValue};

                        return serializer.DeserializeObject(end);
                        }

                        /// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
                        /// <returns>A JSON value-provider object for the specified controller context.</returns>
                        /// <param name="controllerContext">The controller context.</param>
                        public override IValueProvider GetValueProvider(ControllerContext controllerContext)
                        {
                        if (controllerContext == null)
                        throw new ArgumentNullException("controllerContext");
                        object deserializedObject = LargeJsonValueProviderFactory.GetDeserializedObject(controllerContext);
                        if (deserializedObject == null)
                        return (IValueProvider) null;
                        Dictionary<string, object> dictionary = new Dictionary<string, object>((IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase);
                        LargeJsonValueProviderFactory.AddToBackingStore(new LargeJsonValueProviderFactory.EntryLimitedDictionary((IDictionary<string, object>) dictionary), string.Empty, deserializedObject);
                        return (IValueProvider) new DictionaryValueProvider<object>((IDictionary<string, object>) dictionary, CultureInfo.CurrentCulture);
                        }

                        private static string MakeArrayKey(string prefix, int index)
                        {
                        return prefix + "[" + index.ToString((IFormatProvider) CultureInfo.InvariantCulture) + "]";
                        }

                        private static string MakePropertyKey(string prefix, string propertyName)
                        {
                        if (!string.IsNullOrEmpty(prefix))
                        return prefix + "." + propertyName;
                        return propertyName;
                        }

                        private class EntryLimitedDictionary
                        {
                        private static int _maximumDepth = LargeJsonValueProviderFactory.EntryLimitedDictionary.GetMaximumDepth();
                        private readonly IDictionary<string, object> _innerDictionary;
                        private int _itemCount;

                        public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
                        {
                        this._innerDictionary = innerDictionary;
                        }

                        public void Add(string key, object value)
                        {
                        if (++this._itemCount > LargeJsonValueProviderFactory.EntryLimitedDictionary._maximumDepth)
                        throw new InvalidOperationException("JsonValueProviderFactory_RequestTooLarge");
                        this._innerDictionary.Add(key, value);
                        }

                        private static int GetMaximumDepth()
                        {
                        NameValueCollection appSettings = ConfigurationManager.AppSettings;
                        if (appSettings != null)
                        {
                        string values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
                        int result;
                        if (values != null && values.Length > 0 && int.TryParse(values[0], out result))
                        return result;
                        }
                        return 1000;
                        }
                        }


                        }



                        Then, in the Application_Start method from Global.asax.cs, replace the ValueProviderFactory with the new one:



                        protected void Application_Start()
                        {
                        ...

                        //Add LargeJsonValueProviderFactory
                        ValueProviderFactory jsonFactory = null;
                        foreach (var factory in ValueProviderFactories.Factories)
                        {
                        if (factory.GetType().FullName == "System.Web.Mvc.JsonValueProviderFactory")
                        {
                        jsonFactory = factory;
                        break;
                        }
                        }

                        if (jsonFactory != null)
                        {
                        ValueProviderFactories.Factories.Remove(jsonFactory);
                        }

                        var largeJsonValueProviderFactory = new LargeJsonValueProviderFactory();
                        ValueProviderFactories.Factories.Add(largeJsonValueProviderFactory);
                        }





                        share|improve this answer
























                        • I did every thing i can, only your answer saved my day, this should have been accepted answer

                          – Muhammad Waqas Aziz
                          Aug 5 '18 at 14:54











                        • With this code we are able to override MVC controller max json Deserializetion limit of 4 mb, but is there a way to override web-api controller max json Deserializetion limit

                          – Muhammad Waqas Aziz
                          Aug 6 '18 at 4:05
















                        14





                        +50









                        I followed vestigal's answer and got to this solution:



                        When I needed to post a large json to an action in a controller, I would get the famous "Error during deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.rnParameter name: input value provider".



                        What I did is create a new ValueProviderFactory, LargeJsonValueProviderFactory, and set the MaxJsonLength = Int32.MaxValue in the GetDeserializedObject method



                        public sealed class LargeJsonValueProviderFactory : ValueProviderFactory
                        {
                        private static void AddToBackingStore(LargeJsonValueProviderFactory.EntryLimitedDictionary backingStore, string prefix, object value)
                        {
                        IDictionary<string, object> dictionary = value as IDictionary<string, object>;
                        if (dictionary != null)
                        {
                        foreach (KeyValuePair<string, object> keyValuePair in (IEnumerable<KeyValuePair<string, object>>) dictionary)
                        LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);
                        }
                        else
                        {
                        IList list = value as IList;
                        if (list != null)
                        {
                        for (int index = 0; index < list.Count; ++index)
                        LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakeArrayKey(prefix, index), list[index]);
                        }
                        else
                        backingStore.Add(prefix, value);
                        }
                        }

                        private static object GetDeserializedObject(ControllerContext controllerContext)
                        {
                        if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                        return (object) null;
                        string end = new StreamReader(controllerContext.HttpContext.Request.InputStream).ReadToEnd();
                        if (string.IsNullOrEmpty(end))
                        return (object) null;

                        var serializer = new JavaScriptSerializer {MaxJsonLength = Int32.MaxValue};

                        return serializer.DeserializeObject(end);
                        }

                        /// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
                        /// <returns>A JSON value-provider object for the specified controller context.</returns>
                        /// <param name="controllerContext">The controller context.</param>
                        public override IValueProvider GetValueProvider(ControllerContext controllerContext)
                        {
                        if (controllerContext == null)
                        throw new ArgumentNullException("controllerContext");
                        object deserializedObject = LargeJsonValueProviderFactory.GetDeserializedObject(controllerContext);
                        if (deserializedObject == null)
                        return (IValueProvider) null;
                        Dictionary<string, object> dictionary = new Dictionary<string, object>((IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase);
                        LargeJsonValueProviderFactory.AddToBackingStore(new LargeJsonValueProviderFactory.EntryLimitedDictionary((IDictionary<string, object>) dictionary), string.Empty, deserializedObject);
                        return (IValueProvider) new DictionaryValueProvider<object>((IDictionary<string, object>) dictionary, CultureInfo.CurrentCulture);
                        }

                        private static string MakeArrayKey(string prefix, int index)
                        {
                        return prefix + "[" + index.ToString((IFormatProvider) CultureInfo.InvariantCulture) + "]";
                        }

                        private static string MakePropertyKey(string prefix, string propertyName)
                        {
                        if (!string.IsNullOrEmpty(prefix))
                        return prefix + "." + propertyName;
                        return propertyName;
                        }

                        private class EntryLimitedDictionary
                        {
                        private static int _maximumDepth = LargeJsonValueProviderFactory.EntryLimitedDictionary.GetMaximumDepth();
                        private readonly IDictionary<string, object> _innerDictionary;
                        private int _itemCount;

                        public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
                        {
                        this._innerDictionary = innerDictionary;
                        }

                        public void Add(string key, object value)
                        {
                        if (++this._itemCount > LargeJsonValueProviderFactory.EntryLimitedDictionary._maximumDepth)
                        throw new InvalidOperationException("JsonValueProviderFactory_RequestTooLarge");
                        this._innerDictionary.Add(key, value);
                        }

                        private static int GetMaximumDepth()
                        {
                        NameValueCollection appSettings = ConfigurationManager.AppSettings;
                        if (appSettings != null)
                        {
                        string values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
                        int result;
                        if (values != null && values.Length > 0 && int.TryParse(values[0], out result))
                        return result;
                        }
                        return 1000;
                        }
                        }


                        }



                        Then, in the Application_Start method from Global.asax.cs, replace the ValueProviderFactory with the new one:



                        protected void Application_Start()
                        {
                        ...

                        //Add LargeJsonValueProviderFactory
                        ValueProviderFactory jsonFactory = null;
                        foreach (var factory in ValueProviderFactories.Factories)
                        {
                        if (factory.GetType().FullName == "System.Web.Mvc.JsonValueProviderFactory")
                        {
                        jsonFactory = factory;
                        break;
                        }
                        }

                        if (jsonFactory != null)
                        {
                        ValueProviderFactories.Factories.Remove(jsonFactory);
                        }

                        var largeJsonValueProviderFactory = new LargeJsonValueProviderFactory();
                        ValueProviderFactories.Factories.Add(largeJsonValueProviderFactory);
                        }





                        share|improve this answer
























                        • I did every thing i can, only your answer saved my day, this should have been accepted answer

                          – Muhammad Waqas Aziz
                          Aug 5 '18 at 14:54











                        • With this code we are able to override MVC controller max json Deserializetion limit of 4 mb, but is there a way to override web-api controller max json Deserializetion limit

                          – Muhammad Waqas Aziz
                          Aug 6 '18 at 4:05














                        14





                        +50







                        14





                        +50



                        14




                        +50





                        I followed vestigal's answer and got to this solution:



                        When I needed to post a large json to an action in a controller, I would get the famous "Error during deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.rnParameter name: input value provider".



                        What I did is create a new ValueProviderFactory, LargeJsonValueProviderFactory, and set the MaxJsonLength = Int32.MaxValue in the GetDeserializedObject method



                        public sealed class LargeJsonValueProviderFactory : ValueProviderFactory
                        {
                        private static void AddToBackingStore(LargeJsonValueProviderFactory.EntryLimitedDictionary backingStore, string prefix, object value)
                        {
                        IDictionary<string, object> dictionary = value as IDictionary<string, object>;
                        if (dictionary != null)
                        {
                        foreach (KeyValuePair<string, object> keyValuePair in (IEnumerable<KeyValuePair<string, object>>) dictionary)
                        LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);
                        }
                        else
                        {
                        IList list = value as IList;
                        if (list != null)
                        {
                        for (int index = 0; index < list.Count; ++index)
                        LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakeArrayKey(prefix, index), list[index]);
                        }
                        else
                        backingStore.Add(prefix, value);
                        }
                        }

                        private static object GetDeserializedObject(ControllerContext controllerContext)
                        {
                        if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                        return (object) null;
                        string end = new StreamReader(controllerContext.HttpContext.Request.InputStream).ReadToEnd();
                        if (string.IsNullOrEmpty(end))
                        return (object) null;

                        var serializer = new JavaScriptSerializer {MaxJsonLength = Int32.MaxValue};

                        return serializer.DeserializeObject(end);
                        }

                        /// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
                        /// <returns>A JSON value-provider object for the specified controller context.</returns>
                        /// <param name="controllerContext">The controller context.</param>
                        public override IValueProvider GetValueProvider(ControllerContext controllerContext)
                        {
                        if (controllerContext == null)
                        throw new ArgumentNullException("controllerContext");
                        object deserializedObject = LargeJsonValueProviderFactory.GetDeserializedObject(controllerContext);
                        if (deserializedObject == null)
                        return (IValueProvider) null;
                        Dictionary<string, object> dictionary = new Dictionary<string, object>((IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase);
                        LargeJsonValueProviderFactory.AddToBackingStore(new LargeJsonValueProviderFactory.EntryLimitedDictionary((IDictionary<string, object>) dictionary), string.Empty, deserializedObject);
                        return (IValueProvider) new DictionaryValueProvider<object>((IDictionary<string, object>) dictionary, CultureInfo.CurrentCulture);
                        }

                        private static string MakeArrayKey(string prefix, int index)
                        {
                        return prefix + "[" + index.ToString((IFormatProvider) CultureInfo.InvariantCulture) + "]";
                        }

                        private static string MakePropertyKey(string prefix, string propertyName)
                        {
                        if (!string.IsNullOrEmpty(prefix))
                        return prefix + "." + propertyName;
                        return propertyName;
                        }

                        private class EntryLimitedDictionary
                        {
                        private static int _maximumDepth = LargeJsonValueProviderFactory.EntryLimitedDictionary.GetMaximumDepth();
                        private readonly IDictionary<string, object> _innerDictionary;
                        private int _itemCount;

                        public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
                        {
                        this._innerDictionary = innerDictionary;
                        }

                        public void Add(string key, object value)
                        {
                        if (++this._itemCount > LargeJsonValueProviderFactory.EntryLimitedDictionary._maximumDepth)
                        throw new InvalidOperationException("JsonValueProviderFactory_RequestTooLarge");
                        this._innerDictionary.Add(key, value);
                        }

                        private static int GetMaximumDepth()
                        {
                        NameValueCollection appSettings = ConfigurationManager.AppSettings;
                        if (appSettings != null)
                        {
                        string values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
                        int result;
                        if (values != null && values.Length > 0 && int.TryParse(values[0], out result))
                        return result;
                        }
                        return 1000;
                        }
                        }


                        }



                        Then, in the Application_Start method from Global.asax.cs, replace the ValueProviderFactory with the new one:



                        protected void Application_Start()
                        {
                        ...

                        //Add LargeJsonValueProviderFactory
                        ValueProviderFactory jsonFactory = null;
                        foreach (var factory in ValueProviderFactories.Factories)
                        {
                        if (factory.GetType().FullName == "System.Web.Mvc.JsonValueProviderFactory")
                        {
                        jsonFactory = factory;
                        break;
                        }
                        }

                        if (jsonFactory != null)
                        {
                        ValueProviderFactories.Factories.Remove(jsonFactory);
                        }

                        var largeJsonValueProviderFactory = new LargeJsonValueProviderFactory();
                        ValueProviderFactories.Factories.Add(largeJsonValueProviderFactory);
                        }





                        share|improve this answer













                        I followed vestigal's answer and got to this solution:



                        When I needed to post a large json to an action in a controller, I would get the famous "Error during deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.rnParameter name: input value provider".



                        What I did is create a new ValueProviderFactory, LargeJsonValueProviderFactory, and set the MaxJsonLength = Int32.MaxValue in the GetDeserializedObject method



                        public sealed class LargeJsonValueProviderFactory : ValueProviderFactory
                        {
                        private static void AddToBackingStore(LargeJsonValueProviderFactory.EntryLimitedDictionary backingStore, string prefix, object value)
                        {
                        IDictionary<string, object> dictionary = value as IDictionary<string, object>;
                        if (dictionary != null)
                        {
                        foreach (KeyValuePair<string, object> keyValuePair in (IEnumerable<KeyValuePair<string, object>>) dictionary)
                        LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);
                        }
                        else
                        {
                        IList list = value as IList;
                        if (list != null)
                        {
                        for (int index = 0; index < list.Count; ++index)
                        LargeJsonValueProviderFactory.AddToBackingStore(backingStore, LargeJsonValueProviderFactory.MakeArrayKey(prefix, index), list[index]);
                        }
                        else
                        backingStore.Add(prefix, value);
                        }
                        }

                        private static object GetDeserializedObject(ControllerContext controllerContext)
                        {
                        if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                        return (object) null;
                        string end = new StreamReader(controllerContext.HttpContext.Request.InputStream).ReadToEnd();
                        if (string.IsNullOrEmpty(end))
                        return (object) null;

                        var serializer = new JavaScriptSerializer {MaxJsonLength = Int32.MaxValue};

                        return serializer.DeserializeObject(end);
                        }

                        /// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
                        /// <returns>A JSON value-provider object for the specified controller context.</returns>
                        /// <param name="controllerContext">The controller context.</param>
                        public override IValueProvider GetValueProvider(ControllerContext controllerContext)
                        {
                        if (controllerContext == null)
                        throw new ArgumentNullException("controllerContext");
                        object deserializedObject = LargeJsonValueProviderFactory.GetDeserializedObject(controllerContext);
                        if (deserializedObject == null)
                        return (IValueProvider) null;
                        Dictionary<string, object> dictionary = new Dictionary<string, object>((IEqualityComparer<string>) StringComparer.OrdinalIgnoreCase);
                        LargeJsonValueProviderFactory.AddToBackingStore(new LargeJsonValueProviderFactory.EntryLimitedDictionary((IDictionary<string, object>) dictionary), string.Empty, deserializedObject);
                        return (IValueProvider) new DictionaryValueProvider<object>((IDictionary<string, object>) dictionary, CultureInfo.CurrentCulture);
                        }

                        private static string MakeArrayKey(string prefix, int index)
                        {
                        return prefix + "[" + index.ToString((IFormatProvider) CultureInfo.InvariantCulture) + "]";
                        }

                        private static string MakePropertyKey(string prefix, string propertyName)
                        {
                        if (!string.IsNullOrEmpty(prefix))
                        return prefix + "." + propertyName;
                        return propertyName;
                        }

                        private class EntryLimitedDictionary
                        {
                        private static int _maximumDepth = LargeJsonValueProviderFactory.EntryLimitedDictionary.GetMaximumDepth();
                        private readonly IDictionary<string, object> _innerDictionary;
                        private int _itemCount;

                        public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
                        {
                        this._innerDictionary = innerDictionary;
                        }

                        public void Add(string key, object value)
                        {
                        if (++this._itemCount > LargeJsonValueProviderFactory.EntryLimitedDictionary._maximumDepth)
                        throw new InvalidOperationException("JsonValueProviderFactory_RequestTooLarge");
                        this._innerDictionary.Add(key, value);
                        }

                        private static int GetMaximumDepth()
                        {
                        NameValueCollection appSettings = ConfigurationManager.AppSettings;
                        if (appSettings != null)
                        {
                        string values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
                        int result;
                        if (values != null && values.Length > 0 && int.TryParse(values[0], out result))
                        return result;
                        }
                        return 1000;
                        }
                        }


                        }



                        Then, in the Application_Start method from Global.asax.cs, replace the ValueProviderFactory with the new one:



                        protected void Application_Start()
                        {
                        ...

                        //Add LargeJsonValueProviderFactory
                        ValueProviderFactory jsonFactory = null;
                        foreach (var factory in ValueProviderFactories.Factories)
                        {
                        if (factory.GetType().FullName == "System.Web.Mvc.JsonValueProviderFactory")
                        {
                        jsonFactory = factory;
                        break;
                        }
                        }

                        if (jsonFactory != null)
                        {
                        ValueProviderFactories.Factories.Remove(jsonFactory);
                        }

                        var largeJsonValueProviderFactory = new LargeJsonValueProviderFactory();
                        ValueProviderFactories.Factories.Add(largeJsonValueProviderFactory);
                        }






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Jan 10 '17 at 17:51









                        MFAMFA

                        32627




                        32627













                        • I did every thing i can, only your answer saved my day, this should have been accepted answer

                          – Muhammad Waqas Aziz
                          Aug 5 '18 at 14:54











                        • With this code we are able to override MVC controller max json Deserializetion limit of 4 mb, but is there a way to override web-api controller max json Deserializetion limit

                          – Muhammad Waqas Aziz
                          Aug 6 '18 at 4:05



















                        • I did every thing i can, only your answer saved my day, this should have been accepted answer

                          – Muhammad Waqas Aziz
                          Aug 5 '18 at 14:54











                        • With this code we are able to override MVC controller max json Deserializetion limit of 4 mb, but is there a way to override web-api controller max json Deserializetion limit

                          – Muhammad Waqas Aziz
                          Aug 6 '18 at 4:05

















                        I did every thing i can, only your answer saved my day, this should have been accepted answer

                        – Muhammad Waqas Aziz
                        Aug 5 '18 at 14:54





                        I did every thing i can, only your answer saved my day, this should have been accepted answer

                        – Muhammad Waqas Aziz
                        Aug 5 '18 at 14:54













                        With this code we are able to override MVC controller max json Deserializetion limit of 4 mb, but is there a way to override web-api controller max json Deserializetion limit

                        – Muhammad Waqas Aziz
                        Aug 6 '18 at 4:05





                        With this code we are able to override MVC controller max json Deserializetion limit of 4 mb, but is there a way to override web-api controller max json Deserializetion limit

                        – Muhammad Waqas Aziz
                        Aug 6 '18 at 4:05











                        10














                        you can write this line into Controller



                        json.MaxJsonLength = 2147483644;


                        you can also write this line into web.config



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


                        `



                        To be on the safe side, use both.






                        share|improve this answer






























                          10














                          you can write this line into Controller



                          json.MaxJsonLength = 2147483644;


                          you can also write this line into web.config



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


                          `



                          To be on the safe side, use both.






                          share|improve this answer




























                            10












                            10








                            10







                            you can write this line into Controller



                            json.MaxJsonLength = 2147483644;


                            you can also write this line into web.config



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


                            `



                            To be on the safe side, use both.






                            share|improve this answer















                            you can write this line into Controller



                            json.MaxJsonLength = 2147483644;


                            you can also write this line into web.config



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


                            `



                            To be on the safe side, use both.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jul 1 '15 at 7:11









                            Huey

                            3,90562741




                            3,90562741










                            answered Jul 1 '15 at 6:30









                            Pankaj SapkalPankaj Sapkal

                            10112




                            10112























                                9














                                If you are getting this error from the MiniProfiler in MVC then you can increase the value by setting the property MiniProfiler.Settings.MaxJsonResponseSize to the desired value. By default, this tool seems to ignore the value set in config.



                                MiniProfiler.Settings.MaxJsonResponseSize = 104857600;


                                Courtesy mvc-mini-profiler.






                                share|improve this answer




























                                  9














                                  If you are getting this error from the MiniProfiler in MVC then you can increase the value by setting the property MiniProfiler.Settings.MaxJsonResponseSize to the desired value. By default, this tool seems to ignore the value set in config.



                                  MiniProfiler.Settings.MaxJsonResponseSize = 104857600;


                                  Courtesy mvc-mini-profiler.






                                  share|improve this answer


























                                    9












                                    9








                                    9







                                    If you are getting this error from the MiniProfiler in MVC then you can increase the value by setting the property MiniProfiler.Settings.MaxJsonResponseSize to the desired value. By default, this tool seems to ignore the value set in config.



                                    MiniProfiler.Settings.MaxJsonResponseSize = 104857600;


                                    Courtesy mvc-mini-profiler.






                                    share|improve this answer













                                    If you are getting this error from the MiniProfiler in MVC then you can increase the value by setting the property MiniProfiler.Settings.MaxJsonResponseSize to the desired value. By default, this tool seems to ignore the value set in config.



                                    MiniProfiler.Settings.MaxJsonResponseSize = 104857600;


                                    Courtesy mvc-mini-profiler.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Jul 29 '13 at 12:08









                                    WolfyUKWolfyUK

                                    5031618




                                    5031618























                                        7














                                        Simply set MaxJsonLength proprty in MVC's Action method



                                        JsonResult json= Json(classObject, JsonRequestBehavior.AllowGet);
                                        json.MaxJsonLength = int.MaxValue;
                                        return json;





                                        share|improve this answer




























                                          7














                                          Simply set MaxJsonLength proprty in MVC's Action method



                                          JsonResult json= Json(classObject, JsonRequestBehavior.AllowGet);
                                          json.MaxJsonLength = int.MaxValue;
                                          return json;





                                          share|improve this answer


























                                            7












                                            7








                                            7







                                            Simply set MaxJsonLength proprty in MVC's Action method



                                            JsonResult json= Json(classObject, JsonRequestBehavior.AllowGet);
                                            json.MaxJsonLength = int.MaxValue;
                                            return json;





                                            share|improve this answer













                                            Simply set MaxJsonLength proprty in MVC's Action method



                                            JsonResult json= Json(classObject, JsonRequestBehavior.AllowGet);
                                            json.MaxJsonLength = int.MaxValue;
                                            return json;






                                            share|improve this answer












                                            share|improve this answer



                                            share|improve this answer










                                            answered Apr 3 '17 at 11:07









                                            Aftab Ahmed KalhoroAftab Ahmed Kalhoro

                                            11914




                                            11914























                                                6














                                                I suggest setting it to Int32.MaxValue.



                                                JavaScriptSerializer serializer = new JavaScriptSerializer();
                                                serializer.MaxJsonLength = Int32.MaxValue;





                                                share|improve this answer






























                                                  6














                                                  I suggest setting it to Int32.MaxValue.



                                                  JavaScriptSerializer serializer = new JavaScriptSerializer();
                                                  serializer.MaxJsonLength = Int32.MaxValue;





                                                  share|improve this answer




























                                                    6












                                                    6








                                                    6







                                                    I suggest setting it to Int32.MaxValue.



                                                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                                                    serializer.MaxJsonLength = Int32.MaxValue;





                                                    share|improve this answer















                                                    I suggest setting it to Int32.MaxValue.



                                                    JavaScriptSerializer serializer = new JavaScriptSerializer();
                                                    serializer.MaxJsonLength = Int32.MaxValue;






                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited Sep 20 '16 at 2:59









                                                    Aelexe

                                                    97531526




                                                    97531526










                                                    answered Sep 20 '16 at 2:24









                                                    SanthoshSanthosh

                                                    577517




                                                    577517























                                                        6














                                                        How about some attribute magic?



                                                        [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
                                                        public class MaxJsonSizeAttribute : ActionFilterAttribute
                                                        {
                                                        // Default: 10 MB worth of one byte chars
                                                        private int maxLength = 10 * 1024 * 1024;

                                                        public int MaxLength
                                                        {
                                                        set
                                                        {
                                                        if (value < 0) throw new ArgumentOutOfRangeException("value", "Value must be at least 0.");

                                                        maxLength = value;
                                                        }
                                                        get { return maxLength; }
                                                        }

                                                        public override void OnActionExecuted(ActionExecutedContext filterContext)
                                                        {
                                                        JsonResult json = filterContext.Result as JsonResult;
                                                        if (json != null)
                                                        {
                                                        if (maxLength == 0)
                                                        {
                                                        json.MaxJsonLength = int.MaxValue;
                                                        }
                                                        else
                                                        {
                                                        json.MaxJsonLength = maxLength;
                                                        }
                                                        }
                                                        }
                                                        }


                                                        Then you could either apply it globally using the global filter configuration or controller/action-wise.






                                                        share|improve this answer


























                                                        • Very good, this work for me.

                                                          – rosta
                                                          Dec 21 '17 at 12:23











                                                        • this did the trick for me. thx.

                                                          – Sikandar Amla
                                                          Feb 13 '18 at 9:38











                                                        • Great answer. Nice use of custom attributes. Wondering if there is a specific (technical) reason that you set the default to 10 MB worth of one byte chars instead of the Max (int.MaxValue)?

                                                          – Josh
                                                          Jan 22 at 21:41











                                                        • @Josh No, there wasn't any special reason for that.

                                                          – Balázs
                                                          Jan 23 at 7:51
















                                                        6














                                                        How about some attribute magic?



                                                        [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
                                                        public class MaxJsonSizeAttribute : ActionFilterAttribute
                                                        {
                                                        // Default: 10 MB worth of one byte chars
                                                        private int maxLength = 10 * 1024 * 1024;

                                                        public int MaxLength
                                                        {
                                                        set
                                                        {
                                                        if (value < 0) throw new ArgumentOutOfRangeException("value", "Value must be at least 0.");

                                                        maxLength = value;
                                                        }
                                                        get { return maxLength; }
                                                        }

                                                        public override void OnActionExecuted(ActionExecutedContext filterContext)
                                                        {
                                                        JsonResult json = filterContext.Result as JsonResult;
                                                        if (json != null)
                                                        {
                                                        if (maxLength == 0)
                                                        {
                                                        json.MaxJsonLength = int.MaxValue;
                                                        }
                                                        else
                                                        {
                                                        json.MaxJsonLength = maxLength;
                                                        }
                                                        }
                                                        }
                                                        }


                                                        Then you could either apply it globally using the global filter configuration or controller/action-wise.






                                                        share|improve this answer


























                                                        • Very good, this work for me.

                                                          – rosta
                                                          Dec 21 '17 at 12:23











                                                        • this did the trick for me. thx.

                                                          – Sikandar Amla
                                                          Feb 13 '18 at 9:38











                                                        • Great answer. Nice use of custom attributes. Wondering if there is a specific (technical) reason that you set the default to 10 MB worth of one byte chars instead of the Max (int.MaxValue)?

                                                          – Josh
                                                          Jan 22 at 21:41











                                                        • @Josh No, there wasn't any special reason for that.

                                                          – Balázs
                                                          Jan 23 at 7:51














                                                        6












                                                        6








                                                        6







                                                        How about some attribute magic?



                                                        [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
                                                        public class MaxJsonSizeAttribute : ActionFilterAttribute
                                                        {
                                                        // Default: 10 MB worth of one byte chars
                                                        private int maxLength = 10 * 1024 * 1024;

                                                        public int MaxLength
                                                        {
                                                        set
                                                        {
                                                        if (value < 0) throw new ArgumentOutOfRangeException("value", "Value must be at least 0.");

                                                        maxLength = value;
                                                        }
                                                        get { return maxLength; }
                                                        }

                                                        public override void OnActionExecuted(ActionExecutedContext filterContext)
                                                        {
                                                        JsonResult json = filterContext.Result as JsonResult;
                                                        if (json != null)
                                                        {
                                                        if (maxLength == 0)
                                                        {
                                                        json.MaxJsonLength = int.MaxValue;
                                                        }
                                                        else
                                                        {
                                                        json.MaxJsonLength = maxLength;
                                                        }
                                                        }
                                                        }
                                                        }


                                                        Then you could either apply it globally using the global filter configuration or controller/action-wise.






                                                        share|improve this answer















                                                        How about some attribute magic?



                                                        [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
                                                        public class MaxJsonSizeAttribute : ActionFilterAttribute
                                                        {
                                                        // Default: 10 MB worth of one byte chars
                                                        private int maxLength = 10 * 1024 * 1024;

                                                        public int MaxLength
                                                        {
                                                        set
                                                        {
                                                        if (value < 0) throw new ArgumentOutOfRangeException("value", "Value must be at least 0.");

                                                        maxLength = value;
                                                        }
                                                        get { return maxLength; }
                                                        }

                                                        public override void OnActionExecuted(ActionExecutedContext filterContext)
                                                        {
                                                        JsonResult json = filterContext.Result as JsonResult;
                                                        if (json != null)
                                                        {
                                                        if (maxLength == 0)
                                                        {
                                                        json.MaxJsonLength = int.MaxValue;
                                                        }
                                                        else
                                                        {
                                                        json.MaxJsonLength = maxLength;
                                                        }
                                                        }
                                                        }
                                                        }


                                                        Then you could either apply it globally using the global filter configuration or controller/action-wise.







                                                        share|improve this answer














                                                        share|improve this answer



                                                        share|improve this answer








                                                        edited Dec 21 '17 at 13:37

























                                                        answered Jan 17 '17 at 12:28









                                                        BalázsBalázs

                                                        2,38421131




                                                        2,38421131













                                                        • Very good, this work for me.

                                                          – rosta
                                                          Dec 21 '17 at 12:23











                                                        • this did the trick for me. thx.

                                                          – Sikandar Amla
                                                          Feb 13 '18 at 9:38











                                                        • Great answer. Nice use of custom attributes. Wondering if there is a specific (technical) reason that you set the default to 10 MB worth of one byte chars instead of the Max (int.MaxValue)?

                                                          – Josh
                                                          Jan 22 at 21:41











                                                        • @Josh No, there wasn't any special reason for that.

                                                          – Balázs
                                                          Jan 23 at 7:51



















                                                        • Very good, this work for me.

                                                          – rosta
                                                          Dec 21 '17 at 12:23











                                                        • this did the trick for me. thx.

                                                          – Sikandar Amla
                                                          Feb 13 '18 at 9:38











                                                        • Great answer. Nice use of custom attributes. Wondering if there is a specific (technical) reason that you set the default to 10 MB worth of one byte chars instead of the Max (int.MaxValue)?

                                                          – Josh
                                                          Jan 22 at 21:41











                                                        • @Josh No, there wasn't any special reason for that.

                                                          – Balázs
                                                          Jan 23 at 7:51

















                                                        Very good, this work for me.

                                                        – rosta
                                                        Dec 21 '17 at 12:23





                                                        Very good, this work for me.

                                                        – rosta
                                                        Dec 21 '17 at 12:23













                                                        this did the trick for me. thx.

                                                        – Sikandar Amla
                                                        Feb 13 '18 at 9:38





                                                        this did the trick for me. thx.

                                                        – Sikandar Amla
                                                        Feb 13 '18 at 9:38













                                                        Great answer. Nice use of custom attributes. Wondering if there is a specific (technical) reason that you set the default to 10 MB worth of one byte chars instead of the Max (int.MaxValue)?

                                                        – Josh
                                                        Jan 22 at 21:41





                                                        Great answer. Nice use of custom attributes. Wondering if there is a specific (technical) reason that you set the default to 10 MB worth of one byte chars instead of the Max (int.MaxValue)?

                                                        – Josh
                                                        Jan 22 at 21:41













                                                        @Josh No, there wasn't any special reason for that.

                                                        – Balázs
                                                        Jan 23 at 7:51





                                                        @Josh No, there wasn't any special reason for that.

                                                        – Balázs
                                                        Jan 23 at 7:51











                                                        4














                                                        The question really is whether you really need to return 17k records? How are you planning to handle all the data in the browser? The users are not going to scroll through 17000 rows anyway.



                                                        A better approach is to retrieve only a "top few" records and load more as needed.






                                                        share|improve this answer



















                                                        • 1





                                                          The default list from json will give 17k records. But the autocomplete feature will list only the records that matches the characters that the user types, thus it wont need to scroll the list more. SO what i need is to set unlimited length for maxJsonLength which can serialize the 17k data.

                                                          – Prasad
                                                          Jul 20 '09 at 6:53






                                                        • 6





                                                          You could use a combination of server and client side filtering. It could be hard to filter all the data on the client side, not to mention the network latency.

                                                          – Chetan Sastry
                                                          Jul 20 '09 at 7:17






                                                        • 1





                                                          Having arrived at this same issue a while back, I chose to implement an "onsearch" handler for the autocomplete, and have the web service call pass the "search" text and do a Top10 query using the search criteria as a filter. This meant more individual ajax requests, that just getting the full list on page load, but it also meant that all the requests/responses were much smaller.

                                                          – Mike U
                                                          Dec 11 '15 at 21:21
















                                                        4














                                                        The question really is whether you really need to return 17k records? How are you planning to handle all the data in the browser? The users are not going to scroll through 17000 rows anyway.



                                                        A better approach is to retrieve only a "top few" records and load more as needed.






                                                        share|improve this answer



















                                                        • 1





                                                          The default list from json will give 17k records. But the autocomplete feature will list only the records that matches the characters that the user types, thus it wont need to scroll the list more. SO what i need is to set unlimited length for maxJsonLength which can serialize the 17k data.

                                                          – Prasad
                                                          Jul 20 '09 at 6:53






                                                        • 6





                                                          You could use a combination of server and client side filtering. It could be hard to filter all the data on the client side, not to mention the network latency.

                                                          – Chetan Sastry
                                                          Jul 20 '09 at 7:17






                                                        • 1





                                                          Having arrived at this same issue a while back, I chose to implement an "onsearch" handler for the autocomplete, and have the web service call pass the "search" text and do a Top10 query using the search criteria as a filter. This meant more individual ajax requests, that just getting the full list on page load, but it also meant that all the requests/responses were much smaller.

                                                          – Mike U
                                                          Dec 11 '15 at 21:21














                                                        4












                                                        4








                                                        4







                                                        The question really is whether you really need to return 17k records? How are you planning to handle all the data in the browser? The users are not going to scroll through 17000 rows anyway.



                                                        A better approach is to retrieve only a "top few" records and load more as needed.






                                                        share|improve this answer













                                                        The question really is whether you really need to return 17k records? How are you planning to handle all the data in the browser? The users are not going to scroll through 17000 rows anyway.



                                                        A better approach is to retrieve only a "top few" records and load more as needed.







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered Jul 20 '09 at 6:44









                                                        Chetan SastryChetan Sastry

                                                        20.9k25377




                                                        20.9k25377








                                                        • 1





                                                          The default list from json will give 17k records. But the autocomplete feature will list only the records that matches the characters that the user types, thus it wont need to scroll the list more. SO what i need is to set unlimited length for maxJsonLength which can serialize the 17k data.

                                                          – Prasad
                                                          Jul 20 '09 at 6:53






                                                        • 6





                                                          You could use a combination of server and client side filtering. It could be hard to filter all the data on the client side, not to mention the network latency.

                                                          – Chetan Sastry
                                                          Jul 20 '09 at 7:17






                                                        • 1





                                                          Having arrived at this same issue a while back, I chose to implement an "onsearch" handler for the autocomplete, and have the web service call pass the "search" text and do a Top10 query using the search criteria as a filter. This meant more individual ajax requests, that just getting the full list on page load, but it also meant that all the requests/responses were much smaller.

                                                          – Mike U
                                                          Dec 11 '15 at 21:21














                                                        • 1





                                                          The default list from json will give 17k records. But the autocomplete feature will list only the records that matches the characters that the user types, thus it wont need to scroll the list more. SO what i need is to set unlimited length for maxJsonLength which can serialize the 17k data.

                                                          – Prasad
                                                          Jul 20 '09 at 6:53






                                                        • 6





                                                          You could use a combination of server and client side filtering. It could be hard to filter all the data on the client side, not to mention the network latency.

                                                          – Chetan Sastry
                                                          Jul 20 '09 at 7:17






                                                        • 1





                                                          Having arrived at this same issue a while back, I chose to implement an "onsearch" handler for the autocomplete, and have the web service call pass the "search" text and do a Top10 query using the search criteria as a filter. This meant more individual ajax requests, that just getting the full list on page load, but it also meant that all the requests/responses were much smaller.

                                                          – Mike U
                                                          Dec 11 '15 at 21:21








                                                        1




                                                        1





                                                        The default list from json will give 17k records. But the autocomplete feature will list only the records that matches the characters that the user types, thus it wont need to scroll the list more. SO what i need is to set unlimited length for maxJsonLength which can serialize the 17k data.

                                                        – Prasad
                                                        Jul 20 '09 at 6:53





                                                        The default list from json will give 17k records. But the autocomplete feature will list only the records that matches the characters that the user types, thus it wont need to scroll the list more. SO what i need is to set unlimited length for maxJsonLength which can serialize the 17k data.

                                                        – Prasad
                                                        Jul 20 '09 at 6:53




                                                        6




                                                        6





                                                        You could use a combination of server and client side filtering. It could be hard to filter all the data on the client side, not to mention the network latency.

                                                        – Chetan Sastry
                                                        Jul 20 '09 at 7:17





                                                        You could use a combination of server and client side filtering. It could be hard to filter all the data on the client side, not to mention the network latency.

                                                        – Chetan Sastry
                                                        Jul 20 '09 at 7:17




                                                        1




                                                        1





                                                        Having arrived at this same issue a while back, I chose to implement an "onsearch" handler for the autocomplete, and have the web service call pass the "search" text and do a Top10 query using the search criteria as a filter. This meant more individual ajax requests, that just getting the full list on page load, but it also meant that all the requests/responses were much smaller.

                                                        – Mike U
                                                        Dec 11 '15 at 21:21





                                                        Having arrived at this same issue a while back, I chose to implement an "onsearch" handler for the autocomplete, and have the web service call pass the "search" text and do a Top10 query using the search criteria as a filter. This meant more individual ajax requests, that just getting the full list on page load, but it also meant that all the requests/responses were much smaller.

                                                        – Mike U
                                                        Dec 11 '15 at 21:21











                                                        3














                                                        You can set it in the config as others have said, or you can set in on an individual instance of the serializer like:



                                                        var js = new JavaScriptSerializer() { MaxJsonLength = int.MaxValue };





                                                        share|improve this answer




























                                                          3














                                                          You can set it in the config as others have said, or you can set in on an individual instance of the serializer like:



                                                          var js = new JavaScriptSerializer() { MaxJsonLength = int.MaxValue };





                                                          share|improve this answer


























                                                            3












                                                            3








                                                            3







                                                            You can set it in the config as others have said, or you can set in on an individual instance of the serializer like:



                                                            var js = new JavaScriptSerializer() { MaxJsonLength = int.MaxValue };





                                                            share|improve this answer













                                                            You can set it in the config as others have said, or you can set in on an individual instance of the serializer like:



                                                            var js = new JavaScriptSerializer() { MaxJsonLength = int.MaxValue };






                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered Jun 27 '13 at 20:10









                                                            Caleb PostlethwaitCaleb Postlethwait

                                                            8118




                                                            8118























                                                                3














                                                                For those who are having issues with in MVC3 with JSON that's automatically being deserialized for a model binder and is too large, here is a solution.




                                                                1. Copy the code for the JsonValueProviderFactory class from the MVC3 source code into a new class.

                                                                2. Add a line to change the maximum JSON length before the object is deserialized.

                                                                3. Replace the JsonValueProviderFactory class with your new, modified class.


                                                                Thanks to http://blog.naver.com/techshare/100145191355 and https://gist.github.com/DalSoft/1588818 for pointing me in the right direction for how to do this. The last link on the first site contains full source code for the solution.






                                                                share|improve this answer






























                                                                  3














                                                                  For those who are having issues with in MVC3 with JSON that's automatically being deserialized for a model binder and is too large, here is a solution.




                                                                  1. Copy the code for the JsonValueProviderFactory class from the MVC3 source code into a new class.

                                                                  2. Add a line to change the maximum JSON length before the object is deserialized.

                                                                  3. Replace the JsonValueProviderFactory class with your new, modified class.


                                                                  Thanks to http://blog.naver.com/techshare/100145191355 and https://gist.github.com/DalSoft/1588818 for pointing me in the right direction for how to do this. The last link on the first site contains full source code for the solution.






                                                                  share|improve this answer




























                                                                    3












                                                                    3








                                                                    3







                                                                    For those who are having issues with in MVC3 with JSON that's automatically being deserialized for a model binder and is too large, here is a solution.




                                                                    1. Copy the code for the JsonValueProviderFactory class from the MVC3 source code into a new class.

                                                                    2. Add a line to change the maximum JSON length before the object is deserialized.

                                                                    3. Replace the JsonValueProviderFactory class with your new, modified class.


                                                                    Thanks to http://blog.naver.com/techshare/100145191355 and https://gist.github.com/DalSoft/1588818 for pointing me in the right direction for how to do this. The last link on the first site contains full source code for the solution.






                                                                    share|improve this answer















                                                                    For those who are having issues with in MVC3 with JSON that's automatically being deserialized for a model binder and is too large, here is a solution.




                                                                    1. Copy the code for the JsonValueProviderFactory class from the MVC3 source code into a new class.

                                                                    2. Add a line to change the maximum JSON length before the object is deserialized.

                                                                    3. Replace the JsonValueProviderFactory class with your new, modified class.


                                                                    Thanks to http://blog.naver.com/techshare/100145191355 and https://gist.github.com/DalSoft/1588818 for pointing me in the right direction for how to do this. The last link on the first site contains full source code for the solution.







                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited Jul 11 '13 at 17:53

























                                                                    answered Jul 11 '13 at 17:37









                                                                    vestigalvestigal

                                                                    615




                                                                    615























                                                                        2














                                                                        It appears that there is no "unlimited" value. The default is 2097152 characters, which is equivalent to 4 MB of Unicode string data.



                                                                        As as already been observed, 17,000 records are hard to use well in the browser. If you are presenting an aggregate view it may be much more efficient to do the aggregation on the server and transfer only a summary in the browser. For example, consider a file system brower, we only see the top of the tree, then emit further requestes as we drill down. The number of records returned in each request is comparatively small. A tree view presentation can work well for large result sets.






                                                                        share|improve this answer



















                                                                        • 3





                                                                          rather bizarrely the default in code (new JavaScriptSerializer()).MaxJsonLength is 2097152 bytes but the web service ResponseFormatJson is the 102400 bytes unless explicitly set.

                                                                          – rob
                                                                          Jul 24 '14 at 9:56
















                                                                        2














                                                                        It appears that there is no "unlimited" value. The default is 2097152 characters, which is equivalent to 4 MB of Unicode string data.



                                                                        As as already been observed, 17,000 records are hard to use well in the browser. If you are presenting an aggregate view it may be much more efficient to do the aggregation on the server and transfer only a summary in the browser. For example, consider a file system brower, we only see the top of the tree, then emit further requestes as we drill down. The number of records returned in each request is comparatively small. A tree view presentation can work well for large result sets.






                                                                        share|improve this answer



















                                                                        • 3





                                                                          rather bizarrely the default in code (new JavaScriptSerializer()).MaxJsonLength is 2097152 bytes but the web service ResponseFormatJson is the 102400 bytes unless explicitly set.

                                                                          – rob
                                                                          Jul 24 '14 at 9:56














                                                                        2












                                                                        2








                                                                        2







                                                                        It appears that there is no "unlimited" value. The default is 2097152 characters, which is equivalent to 4 MB of Unicode string data.



                                                                        As as already been observed, 17,000 records are hard to use well in the browser. If you are presenting an aggregate view it may be much more efficient to do the aggregation on the server and transfer only a summary in the browser. For example, consider a file system brower, we only see the top of the tree, then emit further requestes as we drill down. The number of records returned in each request is comparatively small. A tree view presentation can work well for large result sets.






                                                                        share|improve this answer













                                                                        It appears that there is no "unlimited" value. The default is 2097152 characters, which is equivalent to 4 MB of Unicode string data.



                                                                        As as already been observed, 17,000 records are hard to use well in the browser. If you are presenting an aggregate view it may be much more efficient to do the aggregation on the server and transfer only a summary in the browser. For example, consider a file system brower, we only see the top of the tree, then emit further requestes as we drill down. The number of records returned in each request is comparatively small. A tree view presentation can work well for large result sets.







                                                                        share|improve this answer












                                                                        share|improve this answer



                                                                        share|improve this answer










                                                                        answered Jul 20 '09 at 6:51









                                                                        djnadjna

                                                                        48.3k106499




                                                                        48.3k106499








                                                                        • 3





                                                                          rather bizarrely the default in code (new JavaScriptSerializer()).MaxJsonLength is 2097152 bytes but the web service ResponseFormatJson is the 102400 bytes unless explicitly set.

                                                                          – rob
                                                                          Jul 24 '14 at 9:56














                                                                        • 3





                                                                          rather bizarrely the default in code (new JavaScriptSerializer()).MaxJsonLength is 2097152 bytes but the web service ResponseFormatJson is the 102400 bytes unless explicitly set.

                                                                          – rob
                                                                          Jul 24 '14 at 9:56








                                                                        3




                                                                        3





                                                                        rather bizarrely the default in code (new JavaScriptSerializer()).MaxJsonLength is 2097152 bytes but the web service ResponseFormatJson is the 102400 bytes unless explicitly set.

                                                                        – rob
                                                                        Jul 24 '14 at 9:56





                                                                        rather bizarrely the default in code (new JavaScriptSerializer()).MaxJsonLength is 2097152 bytes but the web service ResponseFormatJson is the 102400 bytes unless explicitly set.

                                                                        – rob
                                                                        Jul 24 '14 at 9:56











                                                                        2














                                                                        Just ran into this. I'm getting over 6,000 records. Just decided I'd just do some paging. As in, I accept a page number in my MVC JsonResult endpoint, which is defaulted to 0 so it's not necessary, like so:



                                                                        public JsonResult MyObjects(int pageNumber = 0)


                                                                        Then instead of saying:



                                                                        return Json(_repository.MyObjects.ToList(), JsonRequestBehavior.AllowGet);


                                                                        I say:



                                                                        return Json(_repository.MyObjects.OrderBy(obj => obj.ID).Skip(1000 * pageNumber).Take(1000).ToList(), JsonRequestBehavior.AllowGet);


                                                                        It's very simple. Then, in JavaScript, instead of this:



                                                                        function myAJAXCallback(items) {
                                                                        // Do stuff here
                                                                        }


                                                                        I instead say:



                                                                        var pageNumber = 0;
                                                                        function myAJAXCallback(items) {
                                                                        if(items.length == 1000)
                                                                        // Call same endpoint but add this to the end: '?pageNumber=' + ++pageNumber
                                                                        }
                                                                        // Do stuff here
                                                                        }


                                                                        And append your records to whatever you were doing with them in the first place. Or just wait until all the calls finish and cobble the results together.






                                                                        share|improve this answer




























                                                                          2














                                                                          Just ran into this. I'm getting over 6,000 records. Just decided I'd just do some paging. As in, I accept a page number in my MVC JsonResult endpoint, which is defaulted to 0 so it's not necessary, like so:



                                                                          public JsonResult MyObjects(int pageNumber = 0)


                                                                          Then instead of saying:



                                                                          return Json(_repository.MyObjects.ToList(), JsonRequestBehavior.AllowGet);


                                                                          I say:



                                                                          return Json(_repository.MyObjects.OrderBy(obj => obj.ID).Skip(1000 * pageNumber).Take(1000).ToList(), JsonRequestBehavior.AllowGet);


                                                                          It's very simple. Then, in JavaScript, instead of this:



                                                                          function myAJAXCallback(items) {
                                                                          // Do stuff here
                                                                          }


                                                                          I instead say:



                                                                          var pageNumber = 0;
                                                                          function myAJAXCallback(items) {
                                                                          if(items.length == 1000)
                                                                          // Call same endpoint but add this to the end: '?pageNumber=' + ++pageNumber
                                                                          }
                                                                          // Do stuff here
                                                                          }


                                                                          And append your records to whatever you were doing with them in the first place. Or just wait until all the calls finish and cobble the results together.






                                                                          share|improve this answer


























                                                                            2












                                                                            2








                                                                            2







                                                                            Just ran into this. I'm getting over 6,000 records. Just decided I'd just do some paging. As in, I accept a page number in my MVC JsonResult endpoint, which is defaulted to 0 so it's not necessary, like so:



                                                                            public JsonResult MyObjects(int pageNumber = 0)


                                                                            Then instead of saying:



                                                                            return Json(_repository.MyObjects.ToList(), JsonRequestBehavior.AllowGet);


                                                                            I say:



                                                                            return Json(_repository.MyObjects.OrderBy(obj => obj.ID).Skip(1000 * pageNumber).Take(1000).ToList(), JsonRequestBehavior.AllowGet);


                                                                            It's very simple. Then, in JavaScript, instead of this:



                                                                            function myAJAXCallback(items) {
                                                                            // Do stuff here
                                                                            }


                                                                            I instead say:



                                                                            var pageNumber = 0;
                                                                            function myAJAXCallback(items) {
                                                                            if(items.length == 1000)
                                                                            // Call same endpoint but add this to the end: '?pageNumber=' + ++pageNumber
                                                                            }
                                                                            // Do stuff here
                                                                            }


                                                                            And append your records to whatever you were doing with them in the first place. Or just wait until all the calls finish and cobble the results together.






                                                                            share|improve this answer













                                                                            Just ran into this. I'm getting over 6,000 records. Just decided I'd just do some paging. As in, I accept a page number in my MVC JsonResult endpoint, which is defaulted to 0 so it's not necessary, like so:



                                                                            public JsonResult MyObjects(int pageNumber = 0)


                                                                            Then instead of saying:



                                                                            return Json(_repository.MyObjects.ToList(), JsonRequestBehavior.AllowGet);


                                                                            I say:



                                                                            return Json(_repository.MyObjects.OrderBy(obj => obj.ID).Skip(1000 * pageNumber).Take(1000).ToList(), JsonRequestBehavior.AllowGet);


                                                                            It's very simple. Then, in JavaScript, instead of this:



                                                                            function myAJAXCallback(items) {
                                                                            // Do stuff here
                                                                            }


                                                                            I instead say:



                                                                            var pageNumber = 0;
                                                                            function myAJAXCallback(items) {
                                                                            if(items.length == 1000)
                                                                            // Call same endpoint but add this to the end: '?pageNumber=' + ++pageNumber
                                                                            }
                                                                            // Do stuff here
                                                                            }


                                                                            And append your records to whatever you were doing with them in the first place. Or just wait until all the calls finish and cobble the results together.







                                                                            share|improve this answer












                                                                            share|improve this answer



                                                                            share|improve this answer










                                                                            answered Jul 12 '13 at 22:33









                                                                            vbullingervbullinger

                                                                            2,94432030




                                                                            2,94432030























                                                                                2














                                                                                I solved the problem adding this code:



                                                                                String confString = HttpContext.Current.Request.ApplicationPath.ToString();
                                                                                Configuration conf = WebConfigurationManager.OpenWebConfiguration(confString);
                                                                                ScriptingJsonSerializationSection section = (ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization");
                                                                                section.MaxJsonLength = 6553600;
                                                                                conf.Save();





                                                                                share|improve this answer
























                                                                                • This seems like a hackish solution but interesting approach regardless. I found it useful thanks! For me in apsnet mvc 5 controller I had to remove 'Current' from the namespace. I made a couple adjustments: string confString = HttpContext.Request.ApplicationPath.ToString(); var conf = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(confString); var section = (System.Web.Configuration.ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization"); section.MaxJsonLength = int.MaxValue; conf.Save();

                                                                                  – ooXei1sh
                                                                                  Mar 19 '16 at 22:54


















                                                                                2














                                                                                I solved the problem adding this code:



                                                                                String confString = HttpContext.Current.Request.ApplicationPath.ToString();
                                                                                Configuration conf = WebConfigurationManager.OpenWebConfiguration(confString);
                                                                                ScriptingJsonSerializationSection section = (ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization");
                                                                                section.MaxJsonLength = 6553600;
                                                                                conf.Save();





                                                                                share|improve this answer
























                                                                                • This seems like a hackish solution but interesting approach regardless. I found it useful thanks! For me in apsnet mvc 5 controller I had to remove 'Current' from the namespace. I made a couple adjustments: string confString = HttpContext.Request.ApplicationPath.ToString(); var conf = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(confString); var section = (System.Web.Configuration.ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization"); section.MaxJsonLength = int.MaxValue; conf.Save();

                                                                                  – ooXei1sh
                                                                                  Mar 19 '16 at 22:54
















                                                                                2












                                                                                2








                                                                                2







                                                                                I solved the problem adding this code:



                                                                                String confString = HttpContext.Current.Request.ApplicationPath.ToString();
                                                                                Configuration conf = WebConfigurationManager.OpenWebConfiguration(confString);
                                                                                ScriptingJsonSerializationSection section = (ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization");
                                                                                section.MaxJsonLength = 6553600;
                                                                                conf.Save();





                                                                                share|improve this answer













                                                                                I solved the problem adding this code:



                                                                                String confString = HttpContext.Current.Request.ApplicationPath.ToString();
                                                                                Configuration conf = WebConfigurationManager.OpenWebConfiguration(confString);
                                                                                ScriptingJsonSerializationSection section = (ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization");
                                                                                section.MaxJsonLength = 6553600;
                                                                                conf.Save();






                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Nov 20 '14 at 11:57









                                                                                jfabriziojfabrizio

                                                                                634613




                                                                                634613













                                                                                • This seems like a hackish solution but interesting approach regardless. I found it useful thanks! For me in apsnet mvc 5 controller I had to remove 'Current' from the namespace. I made a couple adjustments: string confString = HttpContext.Request.ApplicationPath.ToString(); var conf = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(confString); var section = (System.Web.Configuration.ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization"); section.MaxJsonLength = int.MaxValue; conf.Save();

                                                                                  – ooXei1sh
                                                                                  Mar 19 '16 at 22:54





















                                                                                • This seems like a hackish solution but interesting approach regardless. I found it useful thanks! For me in apsnet mvc 5 controller I had to remove 'Current' from the namespace. I made a couple adjustments: string confString = HttpContext.Request.ApplicationPath.ToString(); var conf = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(confString); var section = (System.Web.Configuration.ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization"); section.MaxJsonLength = int.MaxValue; conf.Save();

                                                                                  – ooXei1sh
                                                                                  Mar 19 '16 at 22:54



















                                                                                This seems like a hackish solution but interesting approach regardless. I found it useful thanks! For me in apsnet mvc 5 controller I had to remove 'Current' from the namespace. I made a couple adjustments: string confString = HttpContext.Request.ApplicationPath.ToString(); var conf = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(confString); var section = (System.Web.Configuration.ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization"); section.MaxJsonLength = int.MaxValue; conf.Save();

                                                                                – ooXei1sh
                                                                                Mar 19 '16 at 22:54







                                                                                This seems like a hackish solution but interesting approach regardless. I found it useful thanks! For me in apsnet mvc 5 controller I had to remove 'Current' from the namespace. I made a couple adjustments: string confString = HttpContext.Request.ApplicationPath.ToString(); var conf = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(confString); var section = (System.Web.Configuration.ScriptingJsonSerializationSection)conf.GetSection("system.web.extensions/scripting/webServices/jsonSerialization"); section.MaxJsonLength = int.MaxValue; conf.Save();

                                                                                – ooXei1sh
                                                                                Mar 19 '16 at 22:54













                                                                                2














                                                                                If you are encountering this sort of issue in View, you can use below method to resolve that. Here Iused Newtonsoft package .



                                                                                @using Newtonsoft.Json
                                                                                <script type="text/javascript">
                                                                                var partData = @Html.Raw(JsonConvert.SerializeObject(ViewBag.Part));
                                                                                </script>





                                                                                share|improve this answer
























                                                                                • Does this mean I don't have to worry about max length if I use Json.NET? I don't think there is a way to set max length in Json.NET so I'm hoping it just works out of the box.

                                                                                  – kimbaudi
                                                                                  Nov 15 '17 at 20:52
















                                                                                2














                                                                                If you are encountering this sort of issue in View, you can use below method to resolve that. Here Iused Newtonsoft package .



                                                                                @using Newtonsoft.Json
                                                                                <script type="text/javascript">
                                                                                var partData = @Html.Raw(JsonConvert.SerializeObject(ViewBag.Part));
                                                                                </script>





                                                                                share|improve this answer
























                                                                                • Does this mean I don't have to worry about max length if I use Json.NET? I don't think there is a way to set max length in Json.NET so I'm hoping it just works out of the box.

                                                                                  – kimbaudi
                                                                                  Nov 15 '17 at 20:52














                                                                                2












                                                                                2








                                                                                2







                                                                                If you are encountering this sort of issue in View, you can use below method to resolve that. Here Iused Newtonsoft package .



                                                                                @using Newtonsoft.Json
                                                                                <script type="text/javascript">
                                                                                var partData = @Html.Raw(JsonConvert.SerializeObject(ViewBag.Part));
                                                                                </script>





                                                                                share|improve this answer













                                                                                If you are encountering this sort of issue in View, you can use below method to resolve that. Here Iused Newtonsoft package .



                                                                                @using Newtonsoft.Json
                                                                                <script type="text/javascript">
                                                                                var partData = @Html.Raw(JsonConvert.SerializeObject(ViewBag.Part));
                                                                                </script>






                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Mar 25 '17 at 10:59









                                                                                dush88cdush88c

                                                                                6931919




                                                                                6931919













                                                                                • Does this mean I don't have to worry about max length if I use Json.NET? I don't think there is a way to set max length in Json.NET so I'm hoping it just works out of the box.

                                                                                  – kimbaudi
                                                                                  Nov 15 '17 at 20:52



















                                                                                • Does this mean I don't have to worry about max length if I use Json.NET? I don't think there is a way to set max length in Json.NET so I'm hoping it just works out of the box.

                                                                                  – kimbaudi
                                                                                  Nov 15 '17 at 20:52

















                                                                                Does this mean I don't have to worry about max length if I use Json.NET? I don't think there is a way to set max length in Json.NET so I'm hoping it just works out of the box.

                                                                                – kimbaudi
                                                                                Nov 15 '17 at 20:52





                                                                                Does this mean I don't have to worry about max length if I use Json.NET? I don't think there is a way to set max length in Json.NET so I'm hoping it just works out of the box.

                                                                                – kimbaudi
                                                                                Nov 15 '17 at 20:52











                                                                                1














                                                                                Alternative ASP.NET MVC 5 Fix:



                                                                                (Mine is similar to MFCs answer above with a few small changes)



                                                                                I wasn't ready to change to Json.NET just yet and in my case the error was occurring during the request. Best approach in my scenario was modifying the actual JsonValueProviderFactory which applies the fix to the global project and can be done by editing the global.cs file as such.



                                                                                JsonValueProviderConfig.Config(ValueProviderFactories.Factories);


                                                                                add a web.config entry:



                                                                                <add key="aspnet:MaxJsonLength" value="20971520" />


                                                                                and then create the two following classes



                                                                                public class JsonValueProviderConfig
                                                                                {
                                                                                public static void Config(ValueProviderFactoryCollection factories)
                                                                                {
                                                                                var jsonProviderFactory = factories.OfType<JsonValueProviderFactory>().Single();
                                                                                factories.Remove(jsonProviderFactory);
                                                                                factories.Add(new CustomJsonValueProviderFactory());
                                                                                }
                                                                                }


                                                                                This is basically an exact copy of the default implementation found in System.Web.Mvc but with the addition of a configurable web.config appsetting value aspnet:MaxJsonLength.



                                                                                public class CustomJsonValueProviderFactory : ValueProviderFactory
                                                                                {

                                                                                /// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
                                                                                /// <returns>A JSON value-provider object for the specified controller context.</returns>
                                                                                /// <param name="controllerContext">The controller context.</param>
                                                                                public override IValueProvider GetValueProvider(ControllerContext controllerContext)
                                                                                {
                                                                                if (controllerContext == null)
                                                                                throw new ArgumentNullException("controllerContext");

                                                                                object deserializedObject = CustomJsonValueProviderFactory.GetDeserializedObject(controllerContext);
                                                                                if (deserializedObject == null)
                                                                                return null;

                                                                                Dictionary<string, object> strs = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(new CustomJsonValueProviderFactory.EntryLimitedDictionary(strs), string.Empty, deserializedObject);

                                                                                return new DictionaryValueProvider<object>(strs, CultureInfo.CurrentCulture);
                                                                                }

                                                                                private static object GetDeserializedObject(ControllerContext controllerContext)
                                                                                {
                                                                                if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                                                                                return null;

                                                                                string fullStreamString = (new StreamReader(controllerContext.HttpContext.Request.InputStream)).ReadToEnd();
                                                                                if (string.IsNullOrEmpty(fullStreamString))
                                                                                return null;

                                                                                var serializer = new JavaScriptSerializer()
                                                                                {
                                                                                MaxJsonLength = CustomJsonValueProviderFactory.GetMaxJsonLength()
                                                                                };
                                                                                return serializer.DeserializeObject(fullStreamString);
                                                                                }

                                                                                private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
                                                                                {
                                                                                IDictionary<string, object> strs = value as IDictionary<string, object>;
                                                                                if (strs != null)
                                                                                {
                                                                                foreach (KeyValuePair<string, object> keyValuePair in strs)
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);

                                                                                return;
                                                                                }

                                                                                IList lists = value as IList;
                                                                                if (lists == null)
                                                                                {
                                                                                backingStore.Add(prefix, value);
                                                                                return;
                                                                                }

                                                                                for (int i = 0; i < lists.Count; i++)
                                                                                {
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakeArrayKey(prefix, i), lists[i]);
                                                                                }
                                                                                }

                                                                                private class EntryLimitedDictionary
                                                                                {
                                                                                private static int _maximumDepth;

                                                                                private readonly IDictionary<string, object> _innerDictionary;

                                                                                private int _itemCount;

                                                                                static EntryLimitedDictionary()
                                                                                {
                                                                                _maximumDepth = CustomJsonValueProviderFactory.GetMaximumDepth();
                                                                                }

                                                                                public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
                                                                                {
                                                                                this._innerDictionary = innerDictionary;
                                                                                }

                                                                                public void Add(string key, object value)
                                                                                {
                                                                                int num = this._itemCount + 1;
                                                                                this._itemCount = num;
                                                                                if (num > _maximumDepth)
                                                                                {
                                                                                throw new InvalidOperationException("The length of the string exceeds the value set on the maxJsonLength property.");
                                                                                }
                                                                                this._innerDictionary.Add(key, value);
                                                                                }
                                                                                }

                                                                                private static string MakeArrayKey(string prefix, int index)
                                                                                {
                                                                                return string.Concat(prefix, "[", index.ToString(CultureInfo.InvariantCulture), "]");
                                                                                }

                                                                                private static string MakePropertyKey(string prefix, string propertyName)
                                                                                {
                                                                                if (string.IsNullOrEmpty(prefix))
                                                                                {
                                                                                return propertyName;
                                                                                }
                                                                                return string.Concat(prefix, ".", propertyName);
                                                                                }

                                                                                private static int GetMaximumDepth()
                                                                                {
                                                                                int num;
                                                                                NameValueCollection appSettings = ConfigurationManager.AppSettings;
                                                                                if (appSettings != null)
                                                                                {
                                                                                string values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
                                                                                if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
                                                                                {
                                                                                return num;
                                                                                }
                                                                                }
                                                                                return 1000;
                                                                                }

                                                                                private static int GetMaxJsonLength()
                                                                                {
                                                                                int num;
                                                                                NameValueCollection appSettings = ConfigurationManager.AppSettings;
                                                                                if (appSettings != null)
                                                                                {
                                                                                string values = appSettings.GetValues("aspnet:MaxJsonLength");
                                                                                if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
                                                                                {
                                                                                return num;
                                                                                }
                                                                                }
                                                                                return 1000;
                                                                                }
                                                                                }





                                                                                share|improve this answer



















                                                                                • 1





                                                                                  Thanks it's working ... Thanks a lot @Maxim Gershkovich

                                                                                  – Jasper Manickaraj
                                                                                  Feb 4 at 10:14
















                                                                                1














                                                                                Alternative ASP.NET MVC 5 Fix:



                                                                                (Mine is similar to MFCs answer above with a few small changes)



                                                                                I wasn't ready to change to Json.NET just yet and in my case the error was occurring during the request. Best approach in my scenario was modifying the actual JsonValueProviderFactory which applies the fix to the global project and can be done by editing the global.cs file as such.



                                                                                JsonValueProviderConfig.Config(ValueProviderFactories.Factories);


                                                                                add a web.config entry:



                                                                                <add key="aspnet:MaxJsonLength" value="20971520" />


                                                                                and then create the two following classes



                                                                                public class JsonValueProviderConfig
                                                                                {
                                                                                public static void Config(ValueProviderFactoryCollection factories)
                                                                                {
                                                                                var jsonProviderFactory = factories.OfType<JsonValueProviderFactory>().Single();
                                                                                factories.Remove(jsonProviderFactory);
                                                                                factories.Add(new CustomJsonValueProviderFactory());
                                                                                }
                                                                                }


                                                                                This is basically an exact copy of the default implementation found in System.Web.Mvc but with the addition of a configurable web.config appsetting value aspnet:MaxJsonLength.



                                                                                public class CustomJsonValueProviderFactory : ValueProviderFactory
                                                                                {

                                                                                /// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
                                                                                /// <returns>A JSON value-provider object for the specified controller context.</returns>
                                                                                /// <param name="controllerContext">The controller context.</param>
                                                                                public override IValueProvider GetValueProvider(ControllerContext controllerContext)
                                                                                {
                                                                                if (controllerContext == null)
                                                                                throw new ArgumentNullException("controllerContext");

                                                                                object deserializedObject = CustomJsonValueProviderFactory.GetDeserializedObject(controllerContext);
                                                                                if (deserializedObject == null)
                                                                                return null;

                                                                                Dictionary<string, object> strs = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(new CustomJsonValueProviderFactory.EntryLimitedDictionary(strs), string.Empty, deserializedObject);

                                                                                return new DictionaryValueProvider<object>(strs, CultureInfo.CurrentCulture);
                                                                                }

                                                                                private static object GetDeserializedObject(ControllerContext controllerContext)
                                                                                {
                                                                                if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                                                                                return null;

                                                                                string fullStreamString = (new StreamReader(controllerContext.HttpContext.Request.InputStream)).ReadToEnd();
                                                                                if (string.IsNullOrEmpty(fullStreamString))
                                                                                return null;

                                                                                var serializer = new JavaScriptSerializer()
                                                                                {
                                                                                MaxJsonLength = CustomJsonValueProviderFactory.GetMaxJsonLength()
                                                                                };
                                                                                return serializer.DeserializeObject(fullStreamString);
                                                                                }

                                                                                private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
                                                                                {
                                                                                IDictionary<string, object> strs = value as IDictionary<string, object>;
                                                                                if (strs != null)
                                                                                {
                                                                                foreach (KeyValuePair<string, object> keyValuePair in strs)
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);

                                                                                return;
                                                                                }

                                                                                IList lists = value as IList;
                                                                                if (lists == null)
                                                                                {
                                                                                backingStore.Add(prefix, value);
                                                                                return;
                                                                                }

                                                                                for (int i = 0; i < lists.Count; i++)
                                                                                {
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakeArrayKey(prefix, i), lists[i]);
                                                                                }
                                                                                }

                                                                                private class EntryLimitedDictionary
                                                                                {
                                                                                private static int _maximumDepth;

                                                                                private readonly IDictionary<string, object> _innerDictionary;

                                                                                private int _itemCount;

                                                                                static EntryLimitedDictionary()
                                                                                {
                                                                                _maximumDepth = CustomJsonValueProviderFactory.GetMaximumDepth();
                                                                                }

                                                                                public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
                                                                                {
                                                                                this._innerDictionary = innerDictionary;
                                                                                }

                                                                                public void Add(string key, object value)
                                                                                {
                                                                                int num = this._itemCount + 1;
                                                                                this._itemCount = num;
                                                                                if (num > _maximumDepth)
                                                                                {
                                                                                throw new InvalidOperationException("The length of the string exceeds the value set on the maxJsonLength property.");
                                                                                }
                                                                                this._innerDictionary.Add(key, value);
                                                                                }
                                                                                }

                                                                                private static string MakeArrayKey(string prefix, int index)
                                                                                {
                                                                                return string.Concat(prefix, "[", index.ToString(CultureInfo.InvariantCulture), "]");
                                                                                }

                                                                                private static string MakePropertyKey(string prefix, string propertyName)
                                                                                {
                                                                                if (string.IsNullOrEmpty(prefix))
                                                                                {
                                                                                return propertyName;
                                                                                }
                                                                                return string.Concat(prefix, ".", propertyName);
                                                                                }

                                                                                private static int GetMaximumDepth()
                                                                                {
                                                                                int num;
                                                                                NameValueCollection appSettings = ConfigurationManager.AppSettings;
                                                                                if (appSettings != null)
                                                                                {
                                                                                string values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
                                                                                if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
                                                                                {
                                                                                return num;
                                                                                }
                                                                                }
                                                                                return 1000;
                                                                                }

                                                                                private static int GetMaxJsonLength()
                                                                                {
                                                                                int num;
                                                                                NameValueCollection appSettings = ConfigurationManager.AppSettings;
                                                                                if (appSettings != null)
                                                                                {
                                                                                string values = appSettings.GetValues("aspnet:MaxJsonLength");
                                                                                if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
                                                                                {
                                                                                return num;
                                                                                }
                                                                                }
                                                                                return 1000;
                                                                                }
                                                                                }





                                                                                share|improve this answer



















                                                                                • 1





                                                                                  Thanks it's working ... Thanks a lot @Maxim Gershkovich

                                                                                  – Jasper Manickaraj
                                                                                  Feb 4 at 10:14














                                                                                1












                                                                                1








                                                                                1







                                                                                Alternative ASP.NET MVC 5 Fix:



                                                                                (Mine is similar to MFCs answer above with a few small changes)



                                                                                I wasn't ready to change to Json.NET just yet and in my case the error was occurring during the request. Best approach in my scenario was modifying the actual JsonValueProviderFactory which applies the fix to the global project and can be done by editing the global.cs file as such.



                                                                                JsonValueProviderConfig.Config(ValueProviderFactories.Factories);


                                                                                add a web.config entry:



                                                                                <add key="aspnet:MaxJsonLength" value="20971520" />


                                                                                and then create the two following classes



                                                                                public class JsonValueProviderConfig
                                                                                {
                                                                                public static void Config(ValueProviderFactoryCollection factories)
                                                                                {
                                                                                var jsonProviderFactory = factories.OfType<JsonValueProviderFactory>().Single();
                                                                                factories.Remove(jsonProviderFactory);
                                                                                factories.Add(new CustomJsonValueProviderFactory());
                                                                                }
                                                                                }


                                                                                This is basically an exact copy of the default implementation found in System.Web.Mvc but with the addition of a configurable web.config appsetting value aspnet:MaxJsonLength.



                                                                                public class CustomJsonValueProviderFactory : ValueProviderFactory
                                                                                {

                                                                                /// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
                                                                                /// <returns>A JSON value-provider object for the specified controller context.</returns>
                                                                                /// <param name="controllerContext">The controller context.</param>
                                                                                public override IValueProvider GetValueProvider(ControllerContext controllerContext)
                                                                                {
                                                                                if (controllerContext == null)
                                                                                throw new ArgumentNullException("controllerContext");

                                                                                object deserializedObject = CustomJsonValueProviderFactory.GetDeserializedObject(controllerContext);
                                                                                if (deserializedObject == null)
                                                                                return null;

                                                                                Dictionary<string, object> strs = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(new CustomJsonValueProviderFactory.EntryLimitedDictionary(strs), string.Empty, deserializedObject);

                                                                                return new DictionaryValueProvider<object>(strs, CultureInfo.CurrentCulture);
                                                                                }

                                                                                private static object GetDeserializedObject(ControllerContext controllerContext)
                                                                                {
                                                                                if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                                                                                return null;

                                                                                string fullStreamString = (new StreamReader(controllerContext.HttpContext.Request.InputStream)).ReadToEnd();
                                                                                if (string.IsNullOrEmpty(fullStreamString))
                                                                                return null;

                                                                                var serializer = new JavaScriptSerializer()
                                                                                {
                                                                                MaxJsonLength = CustomJsonValueProviderFactory.GetMaxJsonLength()
                                                                                };
                                                                                return serializer.DeserializeObject(fullStreamString);
                                                                                }

                                                                                private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
                                                                                {
                                                                                IDictionary<string, object> strs = value as IDictionary<string, object>;
                                                                                if (strs != null)
                                                                                {
                                                                                foreach (KeyValuePair<string, object> keyValuePair in strs)
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);

                                                                                return;
                                                                                }

                                                                                IList lists = value as IList;
                                                                                if (lists == null)
                                                                                {
                                                                                backingStore.Add(prefix, value);
                                                                                return;
                                                                                }

                                                                                for (int i = 0; i < lists.Count; i++)
                                                                                {
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakeArrayKey(prefix, i), lists[i]);
                                                                                }
                                                                                }

                                                                                private class EntryLimitedDictionary
                                                                                {
                                                                                private static int _maximumDepth;

                                                                                private readonly IDictionary<string, object> _innerDictionary;

                                                                                private int _itemCount;

                                                                                static EntryLimitedDictionary()
                                                                                {
                                                                                _maximumDepth = CustomJsonValueProviderFactory.GetMaximumDepth();
                                                                                }

                                                                                public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
                                                                                {
                                                                                this._innerDictionary = innerDictionary;
                                                                                }

                                                                                public void Add(string key, object value)
                                                                                {
                                                                                int num = this._itemCount + 1;
                                                                                this._itemCount = num;
                                                                                if (num > _maximumDepth)
                                                                                {
                                                                                throw new InvalidOperationException("The length of the string exceeds the value set on the maxJsonLength property.");
                                                                                }
                                                                                this._innerDictionary.Add(key, value);
                                                                                }
                                                                                }

                                                                                private static string MakeArrayKey(string prefix, int index)
                                                                                {
                                                                                return string.Concat(prefix, "[", index.ToString(CultureInfo.InvariantCulture), "]");
                                                                                }

                                                                                private static string MakePropertyKey(string prefix, string propertyName)
                                                                                {
                                                                                if (string.IsNullOrEmpty(prefix))
                                                                                {
                                                                                return propertyName;
                                                                                }
                                                                                return string.Concat(prefix, ".", propertyName);
                                                                                }

                                                                                private static int GetMaximumDepth()
                                                                                {
                                                                                int num;
                                                                                NameValueCollection appSettings = ConfigurationManager.AppSettings;
                                                                                if (appSettings != null)
                                                                                {
                                                                                string values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
                                                                                if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
                                                                                {
                                                                                return num;
                                                                                }
                                                                                }
                                                                                return 1000;
                                                                                }

                                                                                private static int GetMaxJsonLength()
                                                                                {
                                                                                int num;
                                                                                NameValueCollection appSettings = ConfigurationManager.AppSettings;
                                                                                if (appSettings != null)
                                                                                {
                                                                                string values = appSettings.GetValues("aspnet:MaxJsonLength");
                                                                                if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
                                                                                {
                                                                                return num;
                                                                                }
                                                                                }
                                                                                return 1000;
                                                                                }
                                                                                }





                                                                                share|improve this answer













                                                                                Alternative ASP.NET MVC 5 Fix:



                                                                                (Mine is similar to MFCs answer above with a few small changes)



                                                                                I wasn't ready to change to Json.NET just yet and in my case the error was occurring during the request. Best approach in my scenario was modifying the actual JsonValueProviderFactory which applies the fix to the global project and can be done by editing the global.cs file as such.



                                                                                JsonValueProviderConfig.Config(ValueProviderFactories.Factories);


                                                                                add a web.config entry:



                                                                                <add key="aspnet:MaxJsonLength" value="20971520" />


                                                                                and then create the two following classes



                                                                                public class JsonValueProviderConfig
                                                                                {
                                                                                public static void Config(ValueProviderFactoryCollection factories)
                                                                                {
                                                                                var jsonProviderFactory = factories.OfType<JsonValueProviderFactory>().Single();
                                                                                factories.Remove(jsonProviderFactory);
                                                                                factories.Add(new CustomJsonValueProviderFactory());
                                                                                }
                                                                                }


                                                                                This is basically an exact copy of the default implementation found in System.Web.Mvc but with the addition of a configurable web.config appsetting value aspnet:MaxJsonLength.



                                                                                public class CustomJsonValueProviderFactory : ValueProviderFactory
                                                                                {

                                                                                /// <summary>Returns a JSON value-provider object for the specified controller context.</summary>
                                                                                /// <returns>A JSON value-provider object for the specified controller context.</returns>
                                                                                /// <param name="controllerContext">The controller context.</param>
                                                                                public override IValueProvider GetValueProvider(ControllerContext controllerContext)
                                                                                {
                                                                                if (controllerContext == null)
                                                                                throw new ArgumentNullException("controllerContext");

                                                                                object deserializedObject = CustomJsonValueProviderFactory.GetDeserializedObject(controllerContext);
                                                                                if (deserializedObject == null)
                                                                                return null;

                                                                                Dictionary<string, object> strs = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(new CustomJsonValueProviderFactory.EntryLimitedDictionary(strs), string.Empty, deserializedObject);

                                                                                return new DictionaryValueProvider<object>(strs, CultureInfo.CurrentCulture);
                                                                                }

                                                                                private static object GetDeserializedObject(ControllerContext controllerContext)
                                                                                {
                                                                                if (!controllerContext.HttpContext.Request.ContentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                                                                                return null;

                                                                                string fullStreamString = (new StreamReader(controllerContext.HttpContext.Request.InputStream)).ReadToEnd();
                                                                                if (string.IsNullOrEmpty(fullStreamString))
                                                                                return null;

                                                                                var serializer = new JavaScriptSerializer()
                                                                                {
                                                                                MaxJsonLength = CustomJsonValueProviderFactory.GetMaxJsonLength()
                                                                                };
                                                                                return serializer.DeserializeObject(fullStreamString);
                                                                                }

                                                                                private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value)
                                                                                {
                                                                                IDictionary<string, object> strs = value as IDictionary<string, object>;
                                                                                if (strs != null)
                                                                                {
                                                                                foreach (KeyValuePair<string, object> keyValuePair in strs)
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakePropertyKey(prefix, keyValuePair.Key), keyValuePair.Value);

                                                                                return;
                                                                                }

                                                                                IList lists = value as IList;
                                                                                if (lists == null)
                                                                                {
                                                                                backingStore.Add(prefix, value);
                                                                                return;
                                                                                }

                                                                                for (int i = 0; i < lists.Count; i++)
                                                                                {
                                                                                CustomJsonValueProviderFactory.AddToBackingStore(backingStore, CustomJsonValueProviderFactory.MakeArrayKey(prefix, i), lists[i]);
                                                                                }
                                                                                }

                                                                                private class EntryLimitedDictionary
                                                                                {
                                                                                private static int _maximumDepth;

                                                                                private readonly IDictionary<string, object> _innerDictionary;

                                                                                private int _itemCount;

                                                                                static EntryLimitedDictionary()
                                                                                {
                                                                                _maximumDepth = CustomJsonValueProviderFactory.GetMaximumDepth();
                                                                                }

                                                                                public EntryLimitedDictionary(IDictionary<string, object> innerDictionary)
                                                                                {
                                                                                this._innerDictionary = innerDictionary;
                                                                                }

                                                                                public void Add(string key, object value)
                                                                                {
                                                                                int num = this._itemCount + 1;
                                                                                this._itemCount = num;
                                                                                if (num > _maximumDepth)
                                                                                {
                                                                                throw new InvalidOperationException("The length of the string exceeds the value set on the maxJsonLength property.");
                                                                                }
                                                                                this._innerDictionary.Add(key, value);
                                                                                }
                                                                                }

                                                                                private static string MakeArrayKey(string prefix, int index)
                                                                                {
                                                                                return string.Concat(prefix, "[", index.ToString(CultureInfo.InvariantCulture), "]");
                                                                                }

                                                                                private static string MakePropertyKey(string prefix, string propertyName)
                                                                                {
                                                                                if (string.IsNullOrEmpty(prefix))
                                                                                {
                                                                                return propertyName;
                                                                                }
                                                                                return string.Concat(prefix, ".", propertyName);
                                                                                }

                                                                                private static int GetMaximumDepth()
                                                                                {
                                                                                int num;
                                                                                NameValueCollection appSettings = ConfigurationManager.AppSettings;
                                                                                if (appSettings != null)
                                                                                {
                                                                                string values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers");
                                                                                if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
                                                                                {
                                                                                return num;
                                                                                }
                                                                                }
                                                                                return 1000;
                                                                                }

                                                                                private static int GetMaxJsonLength()
                                                                                {
                                                                                int num;
                                                                                NameValueCollection appSettings = ConfigurationManager.AppSettings;
                                                                                if (appSettings != null)
                                                                                {
                                                                                string values = appSettings.GetValues("aspnet:MaxJsonLength");
                                                                                if (values != null && values.Length != 0 && int.TryParse(values[0], out num))
                                                                                {
                                                                                return num;
                                                                                }
                                                                                }
                                                                                return 1000;
                                                                                }
                                                                                }






                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Jun 3 '18 at 11:13









                                                                                Maxim GershkovichMaxim Gershkovich

                                                                                18.2k33117211




                                                                                18.2k33117211








                                                                                • 1





                                                                                  Thanks it's working ... Thanks a lot @Maxim Gershkovich

                                                                                  – Jasper Manickaraj
                                                                                  Feb 4 at 10:14














                                                                                • 1





                                                                                  Thanks it's working ... Thanks a lot @Maxim Gershkovich

                                                                                  – Jasper Manickaraj
                                                                                  Feb 4 at 10:14








                                                                                1




                                                                                1





                                                                                Thanks it's working ... Thanks a lot @Maxim Gershkovich

                                                                                – Jasper Manickaraj
                                                                                Feb 4 at 10:14





                                                                                Thanks it's working ... Thanks a lot @Maxim Gershkovich

                                                                                – Jasper Manickaraj
                                                                                Feb 4 at 10:14











                                                                                0














                                                                                use libNewtonsoft.Json.dll



                                                                                public string serializeObj(dynamic json) {        
                                                                                return JsonConvert.SerializeObject(json);
                                                                                }





                                                                                share|improve this answer






























                                                                                  0














                                                                                  use libNewtonsoft.Json.dll



                                                                                  public string serializeObj(dynamic json) {        
                                                                                  return JsonConvert.SerializeObject(json);
                                                                                  }





                                                                                  share|improve this answer




























                                                                                    0












                                                                                    0








                                                                                    0







                                                                                    use libNewtonsoft.Json.dll



                                                                                    public string serializeObj(dynamic json) {        
                                                                                    return JsonConvert.SerializeObject(json);
                                                                                    }





                                                                                    share|improve this answer















                                                                                    use libNewtonsoft.Json.dll



                                                                                    public string serializeObj(dynamic json) {        
                                                                                    return JsonConvert.SerializeObject(json);
                                                                                    }






                                                                                    share|improve this answer














                                                                                    share|improve this answer



                                                                                    share|improve this answer








                                                                                    edited Dec 1 '15 at 13:30









                                                                                    Bartłomiej Semańczyk

                                                                                    34.7k25171239




                                                                                    34.7k25171239










                                                                                    answered Dec 1 '15 at 13:08









                                                                                    Buddhika De SilvaBuddhika De Silva

                                                                                    112




                                                                                    112























                                                                                        0














                                                                                        Solution for WebForms UpdatePanel:



                                                                                        Add a setting to Web.config:



                                                                                        <configuration>
                                                                                        <appSettings>
                                                                                        <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
                                                                                        </appSettings>
                                                                                        </configuration>


                                                                                        https://support.microsoft.com/en-us/kb/981884



                                                                                        ScriptRegistrationManager class contains following code:



                                                                                        // Serialize the attributes to JSON and write them out
                                                                                        JavaScriptSerializer serializer = new JavaScriptSerializer();

                                                                                        // Dev10# 877767 - Allow configurable UpdatePanel script block length
                                                                                        // The default is JavaScriptSerializer.DefaultMaxJsonLength
                                                                                        if (AppSettings.UpdatePanelMaxScriptLength > 0) {
                                                                                        serializer.MaxJsonLength = AppSettings.UpdatePanelMaxScriptLength;
                                                                                        }

                                                                                        string attrText = serializer.Serialize(attrs);





                                                                                        share|improve this answer






























                                                                                          0














                                                                                          Solution for WebForms UpdatePanel:



                                                                                          Add a setting to Web.config:



                                                                                          <configuration>
                                                                                          <appSettings>
                                                                                          <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
                                                                                          </appSettings>
                                                                                          </configuration>


                                                                                          https://support.microsoft.com/en-us/kb/981884



                                                                                          ScriptRegistrationManager class contains following code:



                                                                                          // Serialize the attributes to JSON and write them out
                                                                                          JavaScriptSerializer serializer = new JavaScriptSerializer();

                                                                                          // Dev10# 877767 - Allow configurable UpdatePanel script block length
                                                                                          // The default is JavaScriptSerializer.DefaultMaxJsonLength
                                                                                          if (AppSettings.UpdatePanelMaxScriptLength > 0) {
                                                                                          serializer.MaxJsonLength = AppSettings.UpdatePanelMaxScriptLength;
                                                                                          }

                                                                                          string attrText = serializer.Serialize(attrs);





                                                                                          share|improve this answer




























                                                                                            0












                                                                                            0








                                                                                            0







                                                                                            Solution for WebForms UpdatePanel:



                                                                                            Add a setting to Web.config:



                                                                                            <configuration>
                                                                                            <appSettings>
                                                                                            <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
                                                                                            </appSettings>
                                                                                            </configuration>


                                                                                            https://support.microsoft.com/en-us/kb/981884



                                                                                            ScriptRegistrationManager class contains following code:



                                                                                            // Serialize the attributes to JSON and write them out
                                                                                            JavaScriptSerializer serializer = new JavaScriptSerializer();

                                                                                            // Dev10# 877767 - Allow configurable UpdatePanel script block length
                                                                                            // The default is JavaScriptSerializer.DefaultMaxJsonLength
                                                                                            if (AppSettings.UpdatePanelMaxScriptLength > 0) {
                                                                                            serializer.MaxJsonLength = AppSettings.UpdatePanelMaxScriptLength;
                                                                                            }

                                                                                            string attrText = serializer.Serialize(attrs);





                                                                                            share|improve this answer















                                                                                            Solution for WebForms UpdatePanel:



                                                                                            Add a setting to Web.config:



                                                                                            <configuration>
                                                                                            <appSettings>
                                                                                            <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
                                                                                            </appSettings>
                                                                                            </configuration>


                                                                                            https://support.microsoft.com/en-us/kb/981884



                                                                                            ScriptRegistrationManager class contains following code:



                                                                                            // Serialize the attributes to JSON and write them out
                                                                                            JavaScriptSerializer serializer = new JavaScriptSerializer();

                                                                                            // Dev10# 877767 - Allow configurable UpdatePanel script block length
                                                                                            // The default is JavaScriptSerializer.DefaultMaxJsonLength
                                                                                            if (AppSettings.UpdatePanelMaxScriptLength > 0) {
                                                                                            serializer.MaxJsonLength = AppSettings.UpdatePanelMaxScriptLength;
                                                                                            }

                                                                                            string attrText = serializer.Serialize(attrs);






                                                                                            share|improve this answer














                                                                                            share|improve this answer



                                                                                            share|improve this answer








                                                                                            edited Apr 14 '16 at 5:27

























                                                                                            answered Apr 14 '16 at 5:15









                                                                                            Der_MeisterDer_Meister

                                                                                            3,42012438




                                                                                            3,42012438























                                                                                                0














                                                                                                We don't need any server side changes. you can fix this only modify by web.config file
                                                                                                This helped for me. try this out



                                                                                                <appSettings>
                                                                                                <add key="aspnet:MaxJsonDeserializerMembers" value="2147483647" />
                                                                                                <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
                                                                                                </appSettings>

                                                                                                and

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







                                                                                                share|improve this answer




























                                                                                                  0














                                                                                                  We don't need any server side changes. you can fix this only modify by web.config file
                                                                                                  This helped for me. try this out



                                                                                                  <appSettings>
                                                                                                  <add key="aspnet:MaxJsonDeserializerMembers" value="2147483647" />
                                                                                                  <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
                                                                                                  </appSettings>

                                                                                                  and

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







                                                                                                  share|improve this answer


























                                                                                                    0












                                                                                                    0








                                                                                                    0







                                                                                                    We don't need any server side changes. you can fix this only modify by web.config file
                                                                                                    This helped for me. try this out



                                                                                                    <appSettings>
                                                                                                    <add key="aspnet:MaxJsonDeserializerMembers" value="2147483647" />
                                                                                                    <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
                                                                                                    </appSettings>

                                                                                                    and

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







                                                                                                    share|improve this answer













                                                                                                    We don't need any server side changes. you can fix this only modify by web.config file
                                                                                                    This helped for me. try this out



                                                                                                    <appSettings>
                                                                                                    <add key="aspnet:MaxJsonDeserializerMembers" value="2147483647" />
                                                                                                    <add key="aspnet:UpdatePanelMaxScriptLength" value="2147483647" />
                                                                                                    </appSettings>

                                                                                                    and

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








                                                                                                    share|improve this answer












                                                                                                    share|improve this answer



                                                                                                    share|improve this answer










                                                                                                    answered Aug 11 '17 at 4:19









                                                                                                    isanka thalagalaisanka thalagala

                                                                                                    1471217




                                                                                                    1471217























                                                                                                        -2














                                                                                                        if this maxJsonLength value is a int then how big is its int 32bit/64bit/16bit.... i just want to be sure whats the maximum value i can set as my maxJsonLength



                                                                                                        <scripting>
                                                                                                        <webServices>
                                                                                                        <jsonSerialization maxJsonLength="2147483647">
                                                                                                        </jsonSerialization>
                                                                                                        </webServices>
                                                                                                        </scripting>





                                                                                                        share|improve this answer




























                                                                                                          -2














                                                                                                          if this maxJsonLength value is a int then how big is its int 32bit/64bit/16bit.... i just want to be sure whats the maximum value i can set as my maxJsonLength



                                                                                                          <scripting>
                                                                                                          <webServices>
                                                                                                          <jsonSerialization maxJsonLength="2147483647">
                                                                                                          </jsonSerialization>
                                                                                                          </webServices>
                                                                                                          </scripting>





                                                                                                          share|improve this answer


























                                                                                                            -2












                                                                                                            -2








                                                                                                            -2







                                                                                                            if this maxJsonLength value is a int then how big is its int 32bit/64bit/16bit.... i just want to be sure whats the maximum value i can set as my maxJsonLength



                                                                                                            <scripting>
                                                                                                            <webServices>
                                                                                                            <jsonSerialization maxJsonLength="2147483647">
                                                                                                            </jsonSerialization>
                                                                                                            </webServices>
                                                                                                            </scripting>





                                                                                                            share|improve this answer













                                                                                                            if this maxJsonLength value is a int then how big is its int 32bit/64bit/16bit.... i just want to be sure whats the maximum value i can set as my maxJsonLength



                                                                                                            <scripting>
                                                                                                            <webServices>
                                                                                                            <jsonSerialization maxJsonLength="2147483647">
                                                                                                            </jsonSerialization>
                                                                                                            </webServices>
                                                                                                            </scripting>






                                                                                                            share|improve this answer












                                                                                                            share|improve this answer



                                                                                                            share|improve this answer










                                                                                                            answered Oct 19 '16 at 11:47









                                                                                                            mpho isaac Molellempho isaac Molelle

                                                                                                            1




                                                                                                            1























                                                                                                                -2














                                                                                                                You do not need to do with web.config
                                                                                                                You can use short property during catch value of the passing list
                                                                                                                For example
                                                                                                                declare a model like



                                                                                                                public class BookModel
                                                                                                                {
                                                                                                                public decimal id { get; set; } // 1

                                                                                                                public string BN { get; set; } // 2 Book Name

                                                                                                                public string BC { get; set; } // 3 Bar Code Number

                                                                                                                public string BE { get; set; } // 4 Edition Name

                                                                                                                public string BAL { get; set; } // 5 Academic Level

                                                                                                                public string BCAT { get; set; } // 6 Category
                                                                                                                }


                                                                                                                here i use short proporties like
                                                                                                                BC =barcode
                                                                                                                BE=book edition and so on






                                                                                                                share|improve this answer
























                                                                                                                • This won't help if the bulk of the data is in the property values

                                                                                                                  – Window
                                                                                                                  May 31 '18 at 21:44
















                                                                                                                -2














                                                                                                                You do not need to do with web.config
                                                                                                                You can use short property during catch value of the passing list
                                                                                                                For example
                                                                                                                declare a model like



                                                                                                                public class BookModel
                                                                                                                {
                                                                                                                public decimal id { get; set; } // 1

                                                                                                                public string BN { get; set; } // 2 Book Name

                                                                                                                public string BC { get; set; } // 3 Bar Code Number

                                                                                                                public string BE { get; set; } // 4 Edition Name

                                                                                                                public string BAL { get; set; } // 5 Academic Level

                                                                                                                public string BCAT { get; set; } // 6 Category
                                                                                                                }


                                                                                                                here i use short proporties like
                                                                                                                BC =barcode
                                                                                                                BE=book edition and so on






                                                                                                                share|improve this answer
























                                                                                                                • This won't help if the bulk of the data is in the property values

                                                                                                                  – Window
                                                                                                                  May 31 '18 at 21:44














                                                                                                                -2












                                                                                                                -2








                                                                                                                -2







                                                                                                                You do not need to do with web.config
                                                                                                                You can use short property during catch value of the passing list
                                                                                                                For example
                                                                                                                declare a model like



                                                                                                                public class BookModel
                                                                                                                {
                                                                                                                public decimal id { get; set; } // 1

                                                                                                                public string BN { get; set; } // 2 Book Name

                                                                                                                public string BC { get; set; } // 3 Bar Code Number

                                                                                                                public string BE { get; set; } // 4 Edition Name

                                                                                                                public string BAL { get; set; } // 5 Academic Level

                                                                                                                public string BCAT { get; set; } // 6 Category
                                                                                                                }


                                                                                                                here i use short proporties like
                                                                                                                BC =barcode
                                                                                                                BE=book edition and so on






                                                                                                                share|improve this answer













                                                                                                                You do not need to do with web.config
                                                                                                                You can use short property during catch value of the passing list
                                                                                                                For example
                                                                                                                declare a model like



                                                                                                                public class BookModel
                                                                                                                {
                                                                                                                public decimal id { get; set; } // 1

                                                                                                                public string BN { get; set; } // 2 Book Name

                                                                                                                public string BC { get; set; } // 3 Bar Code Number

                                                                                                                public string BE { get; set; } // 4 Edition Name

                                                                                                                public string BAL { get; set; } // 5 Academic Level

                                                                                                                public string BCAT { get; set; } // 6 Category
                                                                                                                }


                                                                                                                here i use short proporties like
                                                                                                                BC =barcode
                                                                                                                BE=book edition and so on







                                                                                                                share|improve this answer












                                                                                                                share|improve this answer



                                                                                                                share|improve this answer










                                                                                                                answered Apr 3 '18 at 12:53









                                                                                                                N IslamN Islam

                                                                                                                277111




                                                                                                                277111













                                                                                                                • This won't help if the bulk of the data is in the property values

                                                                                                                  – Window
                                                                                                                  May 31 '18 at 21:44



















                                                                                                                • This won't help if the bulk of the data is in the property values

                                                                                                                  – Window
                                                                                                                  May 31 '18 at 21:44

















                                                                                                                This won't help if the bulk of the data is in the property values

                                                                                                                – Window
                                                                                                                May 31 '18 at 21:44





                                                                                                                This won't help if the bulk of the data is in the property values

                                                                                                                – Window
                                                                                                                May 31 '18 at 21:44





                                                                                                                protected by Community Dec 17 '16 at 6:57



                                                                                                                Thank you for your interest in this question.
                                                                                                                Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                                                                                                Would you like to answer one of these unanswered questions instead?



                                                                                                                Popular posts from this blog

                                                                                                                Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                                                                                                                ComboBox Display Member on multiple fields

                                                                                                                Is it possible to collect Nectar points via Trainline?