简体   繁体   English

WCF maxReceivedMessageSize问题

[英]WCF maxReceivedMessageSize issue

I'm having the common error of MaxReceivedMessageSize of 65536. 我遇到了65536的MaxReceivedMessageSize的常见错误。

After reading some of the relevant posts on the forum, I'm still getting this error and just not being able to understand what I am missing. 在阅读了论坛上的一些相关帖子之后,我仍然遇到此错误,只是无法理解我所缺少的内容。

Heres WCF web.config: 这里是WCF web.config:

<?xml version="1.0"?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>

  <system.serviceModel>

  <bindings>
    <basicHttpBinding>
      <binding name="ExtendedMaxSize"
          maxBufferSize="999999" maxReceivedMessageSize="999999" />
    </basicHttpBinding>
  </bindings>
  <services>
    <service name="WCFHaifaNetMobile.Service1" behaviorConfiguration="">

      <endpoint address=""
                binding="basicHttpBinding"
                bindingConfiguration="ExtendedMaxSize"
                contract="WCFHaifaNetMobile.IService1" />
    </service>
  </services>


    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="wsHttpBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

My MVC 4 application config file: 我的MVC 4应用程序配置文件:

<?xml version="1.0"?>



<configuration>

  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>

  </configSections>


  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization"/>
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <appSettings>
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true"/> 
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/> 
  </appSettings>

  <system.web>
      <customErrors mode="Off">
    </customErrors>

    <httpHandlers>
      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
    </httpHandlers>


    <!--
        Enabling request validation in view pages would cause validation to occur
        after the input has already been processed by the controller. By default
        MVC performs request validation before a controller processes the input.
        To change this behavior apply the ValidateInputAttribute to a
        controller or action.
    -->
    <pages
        validateRequest="false"
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <controls>
        <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
      </controls>
    </pages>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />

    <handlers>
      <remove name="BlockViewHandler"/>
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
  </system.webServer>
<system.serviceModel>

  <bindings>
    <basicHttpBinding>
      <binding name="ExtendedMaxSize"
          maxBufferSize="999999" maxReceivedMessageSize="999999" />
    </basicHttpBinding>
  </bindings>
  <services>
    <!-- some how HaifanetMobile.ServiceClient1 is not valid-->
    <service name="HaifanetMobile.ServiceClient1" behaviorConfiguration="">

      <endpoint address=""
                binding="basicHttpBinding"
                bindingConfiguration="ExtendedMaxSize"
                contract="ServiceClient1.IService1" />
    </service>
  </services>

</system.serviceModel>
</configuration>

If you get a error with MaxReceivedMessageSize of 65536 then: 如果在MaxReceivedMessageSize为65536时遇到错误,则:

  • Check the server and client configuration and set on both sides the maxReceivedMessageSize and maxBufferSize to the same value 检查服务器和客户端配置,并在两侧将maxReceivedMessageSize和maxBufferSize设置为相同的值
  • If the error is still there check if you have edited the right config files 如果错误仍然存​​在,请检查您是否编辑了正确的配置文件
  • If the error is still there check if the binding realy is the binding you are using 如果错误仍然存​​在,请检查绑定区域是否为您正在使用的绑定
  • If the error is still there start wcf tracing: wcf tracing , this will tell you exactly if the bad config is on the server or on the client. 如果错误仍然存​​在,请启动wcf跟踪: wcf tracing ,这将准确告诉您错误的配置是在服务器上还是在客户端上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM