![]() However, the maximum message size for ActiveSync is affected by the maxAllowedContentLength value that is applied to all web sites on the server. MaxAllowedContentLength="30000000 bytes" (not present by default see comments)īy default, there is no maxAllowedContentLength key in the web.config files for ActiveSync. %ExchangeInstallPath%ClientAccess\Sync\web.config MaxAllowedContentLength="30000000" (not present by default see comments) %ExchangeInstallPath%FrontEnd\HttpProxy\Sync\web.config For example, if you specify a maximum message size value of 64 MB, you can expect a realistic maximum message size of approximately 48 MB. Base64 encoding increases the size of the message by approximately 33%, so the value you specify should be approximately 33% larger than the actual message size you want enforced. This accounts for the Base64 encoding of attachments and other binary data. Return new DictionaryValueProvider(dictionary, CultureInfo.For any message size limit, you need to set a value that's larger than the actual size you want enforced. IDictionary dictionary = value as IDictionary įoreach (KeyValuePair current in dictionary)ĪddToBackingStore(backingStore, MakePropertyKey(prefix, current.Key), current.Value) įor (int i = 0 i dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase) ĮntryLimitedDictionary backingStore = new EntryLimitedDictionary(dictionary) ĪddToBackingStore(backingStore, string.Empty, deserializedObject) Private static void AddToBackingStore(EntryLimitedDictionary backingStore, string prefix, object value) If (values != null & values.Length > 0 & int.TryParse(values, out result)) String values = appSettings.GetValues("aspnet:MaxJsonDeserializerMembers") NameValueCollection appSettings = ConfigurationManager.AppSettings Throw new InvalidOperationException("itemCount is over maximumDepth") throw new InvalidOperationException(MvcResources.JsonValueProviderFactory_RequestTooLarge) Public void Add(string key, object value) Public EntryLimitedDictionary(IDictionary innerDictionary) Private readonly IDictionary _innerDictionary Private static int _maximumDepth = GetMaximumDepth() Public sealed class MyJsonValueProviderFactory : ValueProviderFactory You can rewrite the JsonValueProviderFactory class and set javaScriptSerializer.MaxJsonLength and then replace this class in Application_Start() methods in Global.asax like this: (().FirstOrDefault()) Return javaScriptSerializer.DeserializeObject(text) JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer() javaScriptSerializer.MaxJsonLength The default value is 2097152 bytes, that is 2. StreamReader streamReader = new StreamReader() ![]() If (!.StartsWith("application/json", StringComparison.OrdinalIgnoreCase)) Actually if you decompile and find the JsonValueProviderFactory class you will see that in GetDeserializedObject methods it has used JavaScriptSerializer without setting any value for MaxJsonLength: private static object GetDeserializedObject(ControllerContext controllerContext) The problem is in JsonValueProviderFactory class in namespace. How can I increase the Max JSON Length for the MVC Controller so that my request can successfully reach the method? Public JsonResult MyMethod (string data = "") Here is the method that I am wanting to POST against: When I debug on a different method within the same controller, I get the default JSON Max Length with the following: Console.WriteLine(new ScriptingJsonSerializationSection().MaxJsonLength) I have tried placing the above in either the root or the Area's Web.Config individually, but neither are working. Now, the controller that I am communicating with is in its own Area, with its own Web.Config. To remedy this, I have tried a number of Web.Config solutions. The value set on the maxJsonLength property. I am sending a POST request to an MVC controller with a large amount of JSON data in the body and it is throwing the following:ĪrgumentException: Error during serialization or deserialization using
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |