.net - 如何将 httpRuntime maxRequestLength ="8096"集成到 app.config [Webservices]

标签 .net web-services

我有一个等待 xml 到达的网络服务。今天我们注意到,XML 有时似乎太大了。现在我想添加 <httpRuntime maxRequestLength="10096" useFullyQualifiedRedirectUrl="true" executionTimeout="120"/>到我的 app.config。不幸的是,它似乎没有任何效果……这是我的 app.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <httpRuntime maxRequestLength="10096"
        useFullyQualifiedRedirectUrl="true"
        executionTimeout="120"/>
  </system.web>

  <system.serviceModel>
    <client />
    <standardEndpoints />
    <services>
      <service behaviorConfiguration="metadataSupport" name="iib.wohnpreis.wohnpreisserver">
        <host>
          <baseAddresses>
            <add baseAddress="URLToWebservice" />
          </baseAddresses>
        </host>
      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding" transferMode="Buffered" useDefaultWebProxy="false">
          <readerQuotas maxStringContentLength="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="metadataSupport">
          <serviceMetadata httpGetEnabled="true" httpGetUrl="wohnpreis/mex" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

有什么错误的建议吗? 谢谢你试图帮助我!

史蒂菲

最佳答案

找到问题了。服务器告诉客户端 maxStringContentLength 被限制为 8096 - 这不是真的,因为我们定义了它

<bindings>
  <basicHttpBinding>
    <binding name="basicHttpBinding" transferMode="Buffered" useDefaultWebProxy="false">
      <readerQuotas maxStringContentLength="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>

不幸的是,这只有在我们删除 name="basicHttpBinding" 时才有效,所以它看起来像

<bindings>
  <basicHttpBinding>
    <binding transferMode="Buffered" useDefaultWebProxy="false">
      <readerQuotas maxStringContentLength="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>

不知道名称如何干扰配置 - 但没有名称它工作正常......

关于.net - 如何将 httpRuntime maxRequestLength ="8096"集成到 app.config [Webservices],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10882493/

相关文章:

.net - 你怎么称呼 IEnumerable<Foo>?

json - TypeScript 在对象数组上使用 forkJoin

.net - WCF中有没有办法在发生异常时处理HTTP响应?

c# - .NET 正则表达式引擎未返回任何匹配项,但我期待 8

.net - 使用级联 CRUD 操作进行单元测试和假存储库实现

.net - 指定 xs :decimal in an XML schema 的小数位数

.net - 在 ASP.NET Core 3.0 .razor 页面中获取当前(登录)用户

linux - 如何使该网络服务器只能由您的计算机和 server1.example.com 访问?

php - Indesign Server soap 响应

c# - 在何处配置 WCF 服务(REST 和 SOAP)