我正在尝试创建一个宁静的 wcf Web 服务。当我尝试通过客户端连接到服务时,出现以下错误:
该服务无法激活,因为它不支持 ASP.NET 兼容性。为此应用程序启用了 ASP.NET 兼容性。在 web.config 中关闭 ASP.NET 兼容模式,或将 AspNetCompatibilityRequirements 属性添加到服务类型,并将 RequirementsMode 设置为“允许”或“必需”。
其他人遇到了问题,但他们通过更改 web.config 解决了问题。我已经实施了他们的修复,但问题仍然存在。这是我的 web.config:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="WebBehavior" >
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="myfirstwcf">
<endpoint address="ws" binding="basicHttpBinding"
contract="Imyfirstwcf" />
<endpoint address="ws2" binding="wsHttpBinding"
contract="Imyfirstwcf" />
<endpoint address="" behaviorConfiguration="WebBehavior"
binding="webHttpBinding"
contract="Imyfirstwcf" />
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled= "true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>