Service Behavior – WCF

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.

servicebehavior

  • 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s