Disconnect session for WCF service

I am trying to disconnect a session for a WCF service by changing the service contract

[ServiceContract(Namespace = "http://company.com/Services/", SessionMode = SessionMode.NotAllowed)]
public interface IService
{ }

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service: IService
{ }

      

But then I enter the operation with the debugger, I see that the HttpContext.Current.Session is a valid object.

What am I missing to disable session state for WCF to work?

+3


source to share


2 answers


This is an old question, but ASP.Net RequirementsMode must be AspNetCompatibilityRequirementsMode.NotAllowed to disconnect session



+2


source


You can use the context mode of the instance. see http://msdn.microsoft.com/en-us/magazine/cc163590.aspx

You have 3 options:



  • Singleton, only one instance of service, common to all calls
  • Per session, the same session until the client proxy was closed.
  • For a call that gets called as soon as the call returns

Sounds like that behind every call. You can see the session object in the debugger, but it will be removed immediately upon invocation.

0


source







All Articles