Maximum request length exceeded in WCF

前端 未结 2 1337
礼貌的吻别
礼貌的吻别 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.

    0 讨论(0)
  • 2020-12-20 00:03

    Change the following setting in web.config

     <configuration> 
        <system.web> 
            <httpRuntime maxRequestLength="xxxx" /> 
        </system.web> 
    </configuration> 
    

    xxxx is the value in KB you want to set it to.

    0 讨论(0)
提交回复
热议问题