RequestEntityTooLarge与WCF OData客户端



我有一个WCF实体服务使用Microsoft.Data.OData服务,托管在IIS与WinForms客户端。

我从WinForms桌面应用程序查询客户端,也做更新和删除。一切都工作得很好,直到数据大小达到某一点-我认为它是64k,然后我收到'RequestEntityTooLarge'错误,当我试图在客户端上SaveChanges()。

我在这里做了谷歌和搜索,发现我应该增加我的服务器配置上的maxReceiveMessageSize。我做了那件事,还做了其他几件事,但都无济于事。消息超过一定的大小仍然失败一次。

这是网页。配置我的服务:

  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" maxRequestLength="2147483647" />
  </system.web>
    <bindings>
      <basicHttpBinding>
        <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647" />
      </basicHttpBinding>
    </bindings>

下面是客户端的配置:

<bindings>
  <basicHttpBinding>
    <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
      maxReceivedMessageSize="2147483647" />
  </basicHttpBinding>
</bindings>
在客户机上,我像这样简单地实例化它:
            _context = new Notification_Entities(new Uri(_oDataServiceURL));

当我调用这个

时它失败了
 _context.SaveChanges();

谢谢你的帮助!

Microsoft.Data.OData绝对与<bindings />的任何设置无关。<httpRuntime maxRequestLength="x" />会有帮助。这将增加。net限制。但是,在IIS上有另一个上传限制。

您需要使用以下命令来提高IIS限制。

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="2000000000" />
        </requestFiltering>
    </security>
</system.webServer>

最新更新