The service cannot be activated because it does not support ASP.NET compatibility

刚刚在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

The service cannot be activated because it does not support ASP.NET compatibility的相关文章

WCF The service cannot be activated because it does not support ASP.NET compatibility

测试发布到虚拟目录中时发生的报错现象,由于不支持asp.net兼容性而导致服务无法激活启用. 具体错误信息如下: Server Error in '/Service2' Application. -------------------------------------------------------------------------------- The service cannot be activated because it does not support ASP.NET com

WCF RIA SERVICE相关技术

WCF RIA SERVICE实体属性拷贝 private void DoSubmit() { ((IEditableObject)this.RepairContract).EndEdit(); var domainContext = new DmsDomainContext(); var newRepairContract = new RepairContract(); domainContext.RepairContracts.Add(newRepairContract); newRepai

does not support ASP.NET compatibility 错误

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 th

转载——Step by Step 创建一个 Web Service

原创地址:http://www.cnblogs.com/jfzhu/p/4022139.html 转载请注明出处 (一)创建Web Service 创建第一个项目,类型选择ASP.NET Empty Web Application 添加一个新项目 Web Service 然后再创建一个类Contact 代码分别如下. Contact.cs: [Serializable] public class Contact { private string name; public string Name

如何创建一个AJAX-Enabled WCF Service

  原创地址:http://www.cnblogs.com/jfzhu/p/4041638.html 转载请注明出处   前面的文章中介绍过<Step by Step 创建一个WCF Service >以及<如何使用WCF的Trace与Message Log功能>,本文介绍如何创建一个AJAX-Enabled WCF Service. (一)创建一个WCF AJAX-enabled service 1. 打开Visual Studio 2012,创建一个ASP.NET Empty

Step by Step 创建一个Web Service

  (一)创建Web Service 创建一个新的解决方案,第一个项目类型选择ASP.NET Empty Web Application     添加一个新项目 Web Service     然后再创建一个类Contact   代码分别如下. Contact.cs:   HelloWebService.asmx:     (二)创建客户端 下面创建一个客户端调用Web Service,检验一下是否正确.创建一个ASP.NET Empty Web Application     添加服务引用  

Apache CXF实现Web Service(4)——Tomcat容器和Spring实现JAX-RS(RESTful) web service

准备 我们仍然使用 Apache CXF实现Web Service(2)——不借助重量级Web容器和Spring实现一个纯的JAX-RS(RESTful) web service 中的代码作为基础,并引入spring来进行RESTful web service的配置和管理. 项目目录结构如下图 首先我们要在web.xml中加入通过Spring的ContextLoaderListener加载的Spring运行时环境以及CXF的Spring配置文件 web.xml <?xml version="

Information Centric Networking Based Service Centric Networking

A method implemented by a network device residing in a service domain, wherein the network device comprises an information centric networking (ICN) transport layer and a service access layer (SAL) for handling context-aware service logistics and serv

Step by Step 创建一个 Web Service

(一)创建Web Service 创建第一个项目.类型选择ASP.NET Empty Web Application 加入一个新项目 Web Service 然后再创建一个类Contact 代码分别例如以下. Contact.cs: [Serializable] public class Contact { private string name; public string Name { get { return name; } set { name = value; } } private