Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing session between WCF services

Tags:

People also ask

Can we use session in WCF service C#?

Default Execution Behavior Using Sessions ServiceModel. SessionMode enumeration values. By default, the value of this property is Allowed, which means that if a client uses a session-based binding with a WCF service implementation, the service establishes and uses the session provided.

Is WCF stateless or stateful?

They are stateless by default and I would highly recommended keeping it that way if possible.

What are the advantages of WCF over Web services?

WCF provides better security and reliablity as compared to web services or ASMX services. Security is a key element in any Service Oriented Architecture (SOA), and it is provided in the form of auditing, authentication, authorization, confidentiality and integrity of messages shared between the client and the service.


I have been working on splitting up the app tier and web tier of a web application. In the app tier, I managed to separate the business logic into a bunch of services exposed using WCF proxies. The problem is that these services talk to another legacy application that uses a large CLR object as its primary means of communication. To keep things quick, I had been keeping a copy of this object in the session after I created it the first time. Now I know that WCF can do sessions, but the session storage is per service whereas my business logic is now split into multiple services (as it should be).

Now the questions:

  1. Is there a way to share session storage between WCF services hosted on the same host?
  2. Is this even something I should be doing?
  3. If not, then what are the best practices here?

This is probably not the first time somebody’s had a large business object on the server. Unfortunately for me, I really do need to cache this object per user (hence the session).

It’s possible the answer is obvious and I'm just not seeing it. Help please!