更新时间:2022-06-25 01:42:21
原文http://www.cnblogs.com/xtechnet/archive/2012/06/06/2537979.html
测试发布到虚拟目录中时发生的报错现象,由于不支持asp.net兼容性而导致服务无法激活启用
错误信息:
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'.
不要看到英文错误信息就一脸迷茫 人家的错误信息显示的很明显了:
1.web.config中增加<serviceHostingEnvironment aspNetCompatibilityEnabled="false">。注意这个是放在<system.serviceModel>中的
2.在wcf的服务类加上附加属性 AspNetCompatibilityRequirements,如下图