Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

rest

asp.net

wcf

I am trying to create a restful wcf web service. When I try to connect to the service through the client I get the following error:

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'.

Others have had problems, but they fixed it through changes to their web.config. I have implemented their fix, but still the problem exists. here is my web.config:

<system.serviceModel>     <behaviors>       <endpointBehaviors>         <behavior name="WebBehavior" >            <webHttp />         </behavior>       </endpointBehaviors>       <serviceBehaviors>         <behavior name="MyServiceBehavior">           <serviceMetadata httpGetEnabled="true" />           <serviceDebug includeExceptionDetailInFaults="true" />         </behavior>         <behavior name="">           <serviceMetadata httpGetEnabled="true" />           <serviceDebug includeExceptionDetailInFaults="false" />         </behavior>       </serviceBehaviors>     </behaviors>     <services>       <service behaviorConfiguration="MyServiceBehavior" name="myfirstwcf">         <endpoint address="ws" binding="basicHttpBinding"                    contract="Imyfirstwcf" />         <endpoint address="ws2" binding="wsHttpBinding"                    contract="Imyfirstwcf" />         <endpoint address="" behaviorConfiguration="WebBehavior"                    binding="webHttpBinding"                    contract="Imyfirstwcf" />         <endpoint address="mex" binding="mexHttpBinding"                    contract="IMetadataExchange" />       </service>     </services>     <serviceHostingEnvironment aspNetCompatibilityEnabled= "true"       multipleSiteBindingsEnabled="true"  />   </system.serviceModel> 
like image 985
user1186651 Avatar asked Aug 10 '12 14:08

user1186651


People also ask

How do I disable compatibility mode in ASP.NET web config?

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'.

What is ASP.NET compatibility mode?

Services running in ASP.NET Compatibility mode participate fully in the ASP.NET application pipeline and can make use of ASP.NET features such as file/URL authorization, session state, and the HttpContext class. The HttpContext class allows access to cookies, sessions, and other ASP.NET features.


1 Answers

On your main service you could mark your service as:

[AspNetCompatibilityRequirements(         RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 

From http://forums.silverlight.net/t/21944.aspx

like image 198
Waqar Janjua Avatar answered Sep 23 '22 22:09

Waqar Janjua