tags:

views:

115

answers:

2

HTTPContext is always null in my WCF calls, is it obsolete or am I doing something wrong?

+2  A: 

The regular HTTPContext is no longer used with WCF. You want the instance context.

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MyService : IMyService
{
    InstanceContext ic = OperationContext.Current.InstanceContext;
}

See this link for more details

http://www.danrigsby.com/blog/index.php/2008/05/23/understanding-instancecontext-in-wcf/

You can also enable compatibility mode so your WCF service acts like an old webservice, but you are better off using the InstanceContext

Bob
A: 

t attribute for your service:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

and add

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

option into web.config "system.serviceModel" section.

Budda