Nir-Z
Nir-Z

Reputation: 869

WCF maxReceivedMessageSize issue

I'm having the common error of MaxReceivedMessageSize of 65536.

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:

<?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:

<?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>

Upvotes: 0

Views: 329

Answers (1)

Peter
Peter

Reputation: 27944

If you get a error with MaxReceivedMessageSize of 65536 then:

  • Check the server and client configuration and set on both sides the maxReceivedMessageSize and maxBufferSize to the same value
  • 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.

Upvotes: 1

Related Questions