Maximum request length exceeded in WCF

前端 未结 2 1361
礼貌的吻别
礼貌的吻别 2020-12-19 23:40

I am currently using Wcf application and getting above mentiooned error in Trace Log.

Below is the Web.Config for Wcf Service.


              


        
2条回答
  •  盖世英雄少女心
    2020-12-19 23:47

    You might have to set the readerQuotas for the binding as shown below:

                WSHttpBinding binding1 = new WSHttpBinding();
                binding1.MaxBufferPoolSize = 2147483647;
                binding1.MaxReceivedMessageSize = 2147483647;            
    
                var myReaderQuotas1 = new XmlDictionaryReaderQuotas();
                myReaderQuotas1.MaxStringContentLength = 2147483647;
                myReaderQuotas1.MaxDepth = 2147483647;
                myReaderQuotas1.MaxArrayLength = 2147483647;
                myReaderQuotas1.MaxBytesPerRead = 2147483647;
                myReaderQuotas1.MaxNameTableCharCount = 2147483647;
                binding1.GetType().GetProperty("ReaderQuotas").SetValue(binding1, myReaderQuotas1, null);
    

    The reason is that setting quotas on a binding that has already been created has no effect.

    Also you would need to consider increasing your "MaxItemsInObjectGraph" value of the DataContractSerializer on both client and server to a large value.

提交回复
热议问题