gpt4 book ai didi

asp.net - WCF Web 服务错误 : The service cannot be activated because it does not support ASP. NET 兼容性

转载 作者:行者123 更新时间:2023-12-03 03:17:34 24 4
gpt4 key购买 nike

我正在尝试创建一个 Restful WCF Web 服务。当我尝试通过客户端连接到服务时,出现以下错误:

The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'.

其他人也遇到过问题,但他们通过更改 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>

最佳答案

在您的主要服务上,您可以将您的服务标记为:

[AspNetCompatibilityRequirements(
RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

来自http://forums.silverlight.net/t/21944.aspx

关于asp.net - WCF Web 服务错误 : The service cannot be activated because it does not support ASP. NET 兼容性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11904202/

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