Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpContext in WCF

Tags:

wcf

To use httpContext I changed app.config and added <serviceHostingEnvironment aspNetCompatibilityEnabled="true"> inside <system.serviceModel>.

I also added using System.Web to my implementation class.

Problem is, httpcontext is not available in my implementation class after doing the required steps.

What I am missing?

like image 740
muhammad kashif Avatar asked May 13 '11 10:05

muhammad kashif


Video Answer


1 Answers

See here: WCF Services and ASP.NET

Within an AppDomain, features implemented by the HTTP runtime apply to ASP.NET content but not to WCF. Many HTTP-specific features of the ASP.NET application platform do not apply to WCF Services hosted inside of an AppDomain that contains ASP.NET content. Examples of these features include the following:

HttpContext: Current is always null when accessed from within a WCF service. Use RequestContext instead.

like image 153
Simon Mourier Avatar answered Oct 07 '22 00:10

Simon Mourier