我有一个 WCF Web 服务,它由 ASP.NET 托管在 .svc 文件中。.svc 文件包含以下配置:
<%@ ServiceHost Language="C#" Debug="true" Service="assembly.IPriceListProvider, assembly" Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf" %>
web.config 包含 WCF 的配置。这是绑定配置:
<binding name="basicHttpBinding_PriceListProvider" maxBufferSize="10485760"
maxReceivedMessageSize="10485760">
<readerQuotas maxArrayLength="16384000" />
</binding>
要测试该服务,我单击 .svc 文件并单击 F5。WCF 测试客户端已打开。但是配置发生了变化。我明确定义的值现在具有默认值:
<binding name="basicHttpBindingEndPoint_PriceListProvider" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
**maxBufferSize="65536"** maxBufferPoolSize="524288" **maxReceivedMessageSize="65536"**
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" **maxArrayLength="16384"**
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
为什么配置会改变?如何保持原始值?
我听说过简化的 .svc 配置:即使您没有在 web.config 中明确指定它,也会配置 .svc 的默认绑定。可以吗?