WCF 无法激活服务,因为它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性

简介: 作者:jiankunking 出处:http://blog.csdn.net/jiankunking错误信息:无法激活服务,因为它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性。请在 web.config 中关闭 ASP.NET 兼容性模式,或将 AspNetCompatibilityRequirements 特性添加到服务类型且同时将 Requiremen

作者:jiankunking 出处:http://blog.csdn.net/jiankunking

错误信息:

无法激活服务,因为它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性。请在 web.config 中关闭 ASP.NET 兼容性模式,或将 AspNetCompatibilityRequirements 特性添加到服务类型且同时将 RequirementsMode 设置为“Allowed”或“Required”。 
说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.InvalidOperationException: 无法激活服务,因为它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性。请在 web.config 中关闭 ASP.NET 兼容性模式,或将 AspNetCompatibilityRequirements 特性添加到服务类型且同时将 RequirementsMode 设置为“Allowed”或“Required”。

源错误: 

执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  

堆栈跟踪: 


[InvalidOperationException: 无法激活服务,因为它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性。请在 web.config 中关闭 ASP.NET 兼容性模式,或将 AspNetCompatibilityRequirements 特性添加到服务类型且同时将 RequirementsMode 设置为“Allowed”或“Required”。]
   System.ServiceModel.Activation.HostedAspNetEnvironment.ValidateCompatibilityRequirements(AspNetCompatibilityRequirementsMode compatibilityMode) +184808
   System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost) +391
   System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +306
   System.ServiceModel.ServiceHostBase.InitializeRuntime() +82
   System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +64
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +789
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +287
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1132

[ServiceActivationException: 由于编译过程中出现异常,无法激活服务“/AMACTEST/RightManagementServer.svc”。异常消息为: 无法激活服务,因为它不支持 ASP.NET 兼容性。已为此应用程序启用了 ASP.NET 兼容性。请在 web.config 中关闭 ASP.NET 兼容性模式,或将 AspNetCompatibilityRequirements 特性添加到服务类型且同时将 RequirementsMode 设置为“Allowed”或“Required”。。]
   System.Runtime.AsyncResult.End(IAsyncResult result) +890624
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +180062
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +136

解决方案:

1、修改相应服务.svc.cs,在类上添加以下标识

using System.ServiceModel.Activation ;
[AspNetCompatibilityRequirements (RequirementsMode=AspNetCompatibilityRequirementsMode.Required)]


据说:启用了AJAX的WCF服务是默认添加的


请移步到小注中的链接,谢谢


小注:

更详细的问题分析参考:

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'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: 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'.





相关文章
|
4月前
|
SQL 开发框架 .NET
分享130个ASP整站程序源码,总有一款适合您
分享130个ASP整站程序源码,总有一款适合您
39 1
|
4月前
|
SQL 开发框架 .NET
分享134个ASP整站程序源码,总有一款适合您
分享134个ASP整站程序源码,总有一款适合您
22 1
|
4月前
|
开发框架 .NET 网络安全
分享128个ASP整站程序源码,总有一款适合您
分享128个ASP整站程序源码,总有一款适合您
21 0
|
4月前
|
开发框架 安全 .NET
分享119个ASP整站程序源码,总有一款适合您
分享119个ASP整站程序源码,总有一款适合您
37 4
|
4月前
|
SQL 开发框架 .NET
分享123个ASP整站程序源码,总有一款适合您
分享123个ASP整站程序源码,总有一款适合您
23 0
|
4月前
|
开发框架 .NET UED
分享111个ASP整站程序源码,总有一款适合您
分享111个ASP整站程序源码,总有一款适合您
32 3
|
4月前
|
SQL 机器学习/深度学习 开发框架
分享95个ASP整站程序源码,总有一款适合您
分享95个ASP整站程序源码,总有一款适合您
23 1
|
15天前
|
开发框架 缓存 前端开发
利用Visual Basic构建高效的ASP.NET Web应用
【4月更文挑战第27天】本文探讨使用Visual Basic与ASP.NET创建高效Web应用的策略,包括了解两者基础、项目规划、MVC架构、数据访问与缓存、代码优化、异步编程、安全性、测试及部署维护。通过这些步骤,开发者能构建出快速、可靠且安全的Web应用,适应不断进步的技术环境。
|
2天前
|
XML 开发框架 .NET
C#/ASP.NET应用程序配置文件app.config/web.config的增、删、改操作
C#/ASP.NET应用程序配置文件app.config/web.config的增、删、改操作
|
4月前
|
开发框架 JavaScript .NET
分享60个ASP精品程序源码,总有一款适合您
分享60个ASP精品程序源码,总有一款适合您
19 1