无法激活服务,因为它不支持 ASP.NET 兼容性

wcf错误直接上图:

原因:

一般是因为程序添加了启用了AJAX的WCF服务而缺少相关设置出现的错误。

解决方案:

1.webconfig

<system.serviceModel>  

        <behaviors>

            <serviceBehaviors>                

      <behavior name="">                    

        <serviceMetadata httpGetEnabled="true" />                

       </behavior>            

    </serviceBehaviors>        

  </behaviors>

</system.serviceModel>

2.cs代码中

using System.ServiceModel.Activation ;

[AspNetCompatibilityRequirements (RequirementsMode=AspNetCompatibilityRequirementsMode.Required)]

欢迎指正:haizi2014@qq.com
原文地址:https://www.cnblogs.com/hcfan/p/4170117.html