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

前端之家收集整理的这篇文章主要介绍了c# – 在WCF服务的web.config文件中放置MaxReceivedMessageSize属性的位置?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要更改我的web.config文件添加MaxReceivedMessageSize属性
我的web.config – 但在哪里?

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

<?xml version="1.0"?>
   <configuration>
      <system.web>
        <compilation debug="false"><assemblies><add assembly="System.Data.Entity,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" /></assemblies></compilation>
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
     <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
      </system.webServer>

解决方法

您需要为要使用的绑定定义绑定配置,然后需要定义服务(在服务器端)和客户端(客户端)上使用该绑定和绑定配置:
<system.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>
原文链接:https://www.f2er.com/csharp/94717.html

猜你在找的C#相关文章