C# · 12月 31, 2021

c# – 在WCF服务的web.config文件中放置MaxReceivedMessageSize属性的位置?

我需要更改我的web.config文件并添加MaxReceivedMessageSize属性
我的web.config – 但在哪里?

传入邮件的最大邮件大小限额(65536)已被超出.要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性.

<?xml version=”1.0″?> <configuration> <sy@R_419_2354@.web> <compilation debug=”false”><assemblies><add assembly=”Sy@R_419_2354@.Data.Entity,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089″ /></assemblies></compilation> </sy@R_419_2354@.web> <sy@R_419_2354@.serviceModel> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled=”true” /> <serviceDebug includeExceptionDetailInFaults=”false” /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled=”true” /> </sy@R_419_2354@.serviceModel> <sy@R_419_2354@.webServer> <modules runAllManagedModulesForAllRequests=”true” /> </sy@R_419_2354@.webServer>解决方法 您需要为要使用的绑定定义绑定配置,然后需要定义服务(在服务器端)和客户端(客户端)上使用该绑定和绑定配置: <sy@R_419_2354@.serviceModel> <bindings> <!– pick whichever binding you want …. –> <basicHttpBinding> <!– binding configuration with a name –> <binding name=”ExtendedMaxSize” maxBufferSize=”999999″ maxReceivedMessageSize=”999999″ /> </basicHttpBinding> </bindings> <services> <service name=”Yournamespace.YourServiceClass” behaviorConfiguration=”…”> <!– define endpoint with your binding and the name of the binding configuration that you have defined just above –> <endpoint address=”” binding=”basicHttpBinding” bindingConfiguration=”ExtendedMaxSize” contract=”Yournamespace.IYourServiceContract” /> </service> </services>