While working with WCF, one can use Service Behavior attribute on the service to define how an instance of the service can be created. There are three different options provided to achieve this feature. As shown below Per Call, Per Session and Single.
- When you declare InstanceContextMode as PerCall, A New Context object is created per each call.
- When InstanceContextMode is set to PerSession, A New Context object is created per session.
- Similarly when InstanceContextMode is set to Single, it becomes Global and servers all requests without recycling.
if no instance exists, one is created on the first request.