Reputation: 3401
We're doing a WCF REST json service (WebHttpBinding). Since pure WCF session doesn't work with this kind of binding, we are using asp.net session. So we set:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
In our web.config, and :
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
On top of our service implementation. We have several service methods such as:
public void OpenSession(string userName)
public void GetSomething(int somethingId)
public void CloseSession()
Then we test the sessionId of the HttpContext in each method.
HttpContext.Current.Session.SessionID
Problem is: it's always changing. If I make a call to OpenSession?userName='toto' in my web browser, and another one right after to GetSomething?somethingId=1234, the session id will change.
It seems that the cookies aren't well handled by wcf. If I call the OpenSession method in fiddler, in the http headers, there're no 'Set-Cookie' returned by the service.
Upvotes: 1
Views: 1870
Reputation: 16013
I found that :
By default, WCF does not have cookie enabled on the client side. So when the server requires Cookie, you need to turn on the cookie on the binding for the client through the property HttpTransportBindingElement.AllowCookies.
It's in this article. Checki if it will be usefull for you : http://blogs.msdn.com/b/wenlong/archive/2006/01/23/516041.aspx
Upvotes: 1