gpt4 book ai didi

C# WCF Web Api 4 MaxReceivedMessageSize

转载 作者:太空狗 更新时间:2023-10-29 21:10:34 26 4
gpt4 key购买 nike

我正在使用 WCF Web Api 4.0 框架并遇到 maxReceivedMessageSize has exceeded 65,000 错误。

我已经将我的 webconfig 更新为如下所示,但是因为我正在使用 WCF Web Api,所以我认为这甚至不再使用了,因为我不再使用 webHttpEndpoint?

<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name=""
helpEnabled="true"
automaticFormatSelectionEnabled="true"
maxReceivedMessageSize="4194304" />

</webHttpEndpoint>

在新的 WCF Web Api 中的什么位置指定 MaxReceivedMessageSize?

我也试过 CustomHttpOperationHandlerFactory 但无济于事:

  public class CustomHttpOperationHandlerFactory: HttpOperationHandlerFactory
{
protected override System.Collections.ObjectModel.Collection<HttpOperationHandler> OnCreateRequestHandlers(System.ServiceModel.Description.ServiceEndpoint endpoint, HttpOperationDescription operation)
{
var binding = (HttpBinding)endpoint.Binding;
binding.MaxReceivedMessageSize = Int32.MaxValue;

return base.OnCreateRequestHandlers(endpoint, operation);
}
}

最佳答案

maxReceivedMessageSize 是您必须在您使用的绑定(bind)上定义的属性。 .Net 4 中的 WCF 引入了简化配置,因此如果您不配置任何内容,将使用默认值。下面的示例对 wshttpBinding 有效,您可以根据您使用的绑定(bind)对其进行修改,并在服务模型绑定(bind)部分的 web.config 中注册它(假设您使用的是 IIS 托管服务)。

<wsHttpBinding>
<binding name="CalculatorBinding" maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000000" >
<security mode="Transport" >
<transport clientCredentialType="Windows" />
</security>
<readerQuotas maxDepth="2000000" maxStringContentLength="2000000"
maxArrayLength="2000000"
maxBytesPerRead="2000000"
maxNameTableCharCount="2000000" />
</binding>
</wsHttpBinding>

HTH多米尼克

关于C# WCF Web Api 4 MaxReceivedMessageSize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6462571/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com