【发布时间】:2019-10-01 16:40:56
【问题描述】:
在 ASP.NET 4.52、Silverlight 客户端下运行的 WCF 服务。该应用程序在 Windows 2008 R2 上托管时可以正常工作。现在我已经在 Windows 2016 服务器上设置了它,并且第一个服务调用错误并出现错误 405 - 方法不允许。这里的方法是 POST。错误描述如下:
405 - 不允许用于访问此页面的 HTTP 动词。
在基于 Windows 2008 的实例上,它也是 POST,但后端对此没有问题。该服务使用 HTTPS 和 Windows 身份验证。
相关的 Web.config 位是:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="winAuthBasicHttpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
<security mode="Transport">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Foo.Web.Services.FooBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="Foo.Web.Services.FooBehavior" name="Foo.Web.Services.FooService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="winAuthBasicHttpBinding" contract="Foo.Web.Services.IFooService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</service>
</services>
</system.serviceModel>
错误方法除了[OperationContract] 之外没有其他注释。接口只有[ServiceContract]。服务类有:
[WcfErrorBehavior]
[WcfSilverlightFaultBehavior]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
方法没有参数可能是相关的;我相信最新版本的 WCF 对这些使用 GET。该应用程序很旧。
使用通用 HTTP 客户端会重现该错误,它并非特定于 Silverlight 前端。
.NET 版本之间的机器级 WCF 配置似乎有所不同。不太可能的是,Windows 2016 盒子上缺少 Windows 组件。
编辑:启用请求跟踪,得到了一些回报。有一个通知EXECUTE_REQUEST_HANDLER 发送到StaticFileModule。 WCF 服务绝对不是静态文件。
【问题讨论】:
-
您是否尝试在 2016 服务器上启用旧版本的 .NET Framework?
-
请问怎么样?我以为默认启用了整个 4.x 分支。
标签: c# web-services wcf