Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET WCF
I'm trying to host a WCF service inside a asp.net MVC application using AspNetCompatibility so that i could access the HttpContext, i have added the following line to my Web.config under system.serviceModel:
 
<servicehostingenvironment aspnetcompatibilityenabled="true"></servicehostingenvironment>
 
and the following attribute to my service class:
 
[AspNetCompatibilityRequirements(RequirementsMode= AspNetCompatibilityRequirementsMode.Allowed)]
 
but the HttpContex.Current is still null, what am i missing?
Posted 10-Nov-11 4:21am
huotari420
Edited 10-Nov-11 4:47am
v2
Comments
RaisKazi at 10-Nov-11 9:38am
   
I had posted Answer with suggestion - Web.config is case-sensitive, check you have specified it as "aspNetCompatibilityEnabled".
 
Probably you may have specified it correctly but after "pre" tag it's became as "aspnetcompatibilityenabled". Do check it once in your web.config.
huotari at 10-Nov-11 9:51am
   
it is specified aspNetCompatibilityEnabled and not aspnetcompatibilityenabled
RaisKazi at 10-Nov-11 10:01am
   
Yup, I realized it later :), "pre" tag seems to be converting it to small letters.
RaisKazi at 10-Nov-11 10:10am
   

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Your exception message states "This service requires ASP.NET compatibility and must be hosted in IIS. Either host the service in IIS with ASP.NET compatibility turned on in web.config or set the AspNetCompatibilityRequirementsAttribute.AspNetCompatibilityRequirementsMode property to a value other than Required."
 
and you've posted:
 
[AspNetCompatibilityRequirements(RequirementsMode= AspNetCompatibilityRequirementsMode.Required)]
 
You need to set the value to something other than required.
  Permalink  
Comments
huotari at 10-Nov-11 9:31am
   
I tried that but then the HttpContext.Current was null

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 562
1 Sergey Alexandrovich Kryukov 484
2 Maciej Los 325
3 DamithSL 233
4 Mathew Soji 195
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 10 Nov 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100