加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 06:46:00 所属栏目:百科 来源:网络整理
导读:我需要更改我的web.config文件并添加MaxReceivedMessageSize属性 我的web.config – 但在哪里? 传入邮件的最大邮件大小限额(65536)已被超出.要增加配额,请在适当的绑定元素上使用MaxReceivedMessageSize属性. ?xml version="1.0"? configuration system.web
我需要更改我的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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读