Is HTTPContext obsolete in WCF?

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

+2


source to share


2 answers


Plain HTTPContext is no longer used with WCF. You need an instance context.

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

      

See this link for details



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

You can also enable compatibility mode to make your WCF service act like an old web service, but you are better off using InstanceContext

+2


source


t for your service:

[AspNetCompatibilityRequirements (RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

and add



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

      

For more information, see the web.config "system.serviceModel" section.

+1


source







All Articles