我正在try 创建一个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'.

其他人也有问题,但他们通过改变网络来解决.配置.我已经实施了他们的修复,但问题仍然存在.这是我的网站.配置:

<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相关问答推荐

禁用托管优化并重新启动调试实际上在 Visual Studio 中更改了哪些设置?

在每个对象上设置 ClientIDMode = Static 是否有任何缺点(在母版页的 maincontent 上设置)

业务逻辑中的实体框架最佳实践?

如何判断一个IP地址是否是私有的?

c# - 如何从列表中获取值的总和?

Request.Params 和 Request.Form 什么时候不同?

来自 IP 地址的经度和纬度值

ASP.Net 自定义客户端验证

将通用列表绑定到转发器 - ASP.NET

如何在 ASP.NET 站点中添加 favicon.ico

单击按钮时播放哔声

<%# Eval("State") %> 或 <%# DataBinder.Eval(Container.DataItem, "state")%>

无法在 IIS 中启动网站 - W3SVC 正在运行

使用 VirtualPathProvider 从 DLL 加载 ASP.NET MVC 视图

将 MemoryStream 写入响应对象

如何遍历自定义 vb.net 对象的每个属性?

asp.net core 2.0 - 值不能为空.参数名称:连接字符串

IIS 是否执行非法字符替换?如果是这样,如何阻止它?

可以在不 destruct 站点的情况下将 MIME 类型添加到 web.config 吗?

配置授权服务器端点