WCF服务远程服务器返回意外响应:(413)请求实体太大

时间:2016-03-08 05:59:20

标签: c# .net asp.net-mvc wcf

我得到一个像

这样的例外
  

“远程服务器返回了意外响应:(413)请求   实体太大了。“

从我的MVC应用程序(客户端)上传413KB文件到我的WCF服务。可以请任何人帮我解决这个问题吗?我不知道出了什么问题。

服务器堆栈跟踪:    在

System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

在[0]处重新抛出异常:

  

在   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(即时聊天   reqMsg,IMessage retMsg)at   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&安培;   msgData,Int32类型)

at

客户端Web.config

<system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true" logMessagesAtTransportLevel="true"/>
      <endToEndTracing propagateActivity="true" activityTracing="true" messageFlowTracing="true"/>
    </diagnostics>
    <bindings>

      <basicHttpBinding>
        <binding name="BasicHttpBinding_IWebClientService" allowCookies="true" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
          closeTimeout="20:20:00"  openTimeout="20:20:00" sendTimeout="20:20:00" receiveTimeout="20:20:00">
        </binding>

        <binding name="BasicHttpBinding_IReports" allowCookies="true" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
              closeTimeout="20:20:00"  openTimeout="20:20:00" sendTimeout="20:20:00" receiveTimeout="20:20:00">
        </binding>

        <binding name="BasicHttpBinding_IHealthCheckService" allowCookies="true" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
                  closeTimeout="20:20:00"  openTimeout="20:20:00" sendTimeout="20:20:00" receiveTimeout="20:20:00">
        </binding>

        <binding name="BasicHttpBinding_IUserService" allowCookies="true" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
                   closeTimeout="20:20:00"  openTimeout="20:20:00" sendTimeout="20:20:00" receiveTimeout="20:20:00">
        </binding>
      </basicHttpBinding>

    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="endPointBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <client>
      <endpoint address="http://localhost:5572/HealthCheckService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHealthCheckService" contract="HCSSS.IHealthCheckService" name="BasicHttpBinding_IHealthCheckService"/>
      <endpoint address="http://localhost:5572/Reports.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReports" contract="ReportService.IReports" name="BasicHttpBinding_IReports"/>
      <endpoint address="http://localhost:5572/UserService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserService" contract="UserService.IUserService" name="BasicHttpBinding_IUserService"/>
      <endpoint address="http://localhost:5572/WebClientService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWebClientService" contract="WebClientService.IWebClientService" name="BasicHttpBinding_IWebClientService"/>
    </client>
  </system.serviceModel>
    <system.webServer>
    <security>
      <requestFiltering>        
        <requestLimits maxAllowedContentLength="2147483647"/>
      </requestFiltering>
    </security>
     </system.webServer>

服务器Web.config

<system.serviceModel>
    <diagnostics>
      <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
      <endToEndTracing propagateActivity="true" activityTracing="true" messageFlowTracing="true" />
    </diagnostics>
    <bindings>

      <basicHttpBinding>
        <binding name="BasicHttpBinding_IWebClientService" allowCookies="true"
              maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
                 closeTimeout="20:20:00"  openTimeout="20:20:00" sendTimeout="20:20:00" receiveTimeout="20:20:00">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" />
        </binding>

        <binding name="BasicHttpBinding_IReports" allowCookies="true"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
                closeTimeout="20:20:00"  openTimeout="20:20:00" sendTimeout="20:20:00" receiveTimeout="20:20:00">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" />
        </binding>

        <binding name="BasicHttpBinding_IHealthCheckService" allowCookies="true"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
                closeTimeout="20:20:00"  openTimeout="20:20:00" sendTimeout="20:20:00" receiveTimeout="20:20:00">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" />
        </binding>

        <binding name="BasicHttpBinding_IUserService" allowCookies="true"
          maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
                 closeTimeout="20:20:00"  openTimeout="20:20:00" sendTimeout="20:20:00" receiveTimeout="20:20:00">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <!--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="true" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior>
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpBinding" scheme="http"  />
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <security>
      <requestFiltering>
        <!--<requestLimits maxAllowedContentLength="2147483647" />-->
        <requestLimits maxAllowedContentLength="2147483647" />
      </requestFiltering>
    </security>
    <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>

0 个答案:

没有答案