刚刚在ASP.NET创建一个Service,在运行时,它即显示异常:
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‘.
解决方法,你需要为你的Service添加一个属性:
第#11行代码:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
上面的解决方法,它只是为单独某一个Service。如果你有多个Service时,那需要在每一个Service均需要添加上面的属性。
有一个更好的方法,就是修改web.config:
时间: 2024-12-27 22:27:24