What is the use of ServiceBehavior attribute in WCF ?

 Posted by Raja on 5/5/2010 | Category: WCF Interview questions | Views: 31169
Answer:

ServiceBehaviour attribute is used to specify the InstanceContextMode for the WCF Service class (This can be used to maintained a state of the service or a client too)

There are three instance Context Mode in the WFC

PerSession : This is used to create a new instance for a service and the same instance is used for all method for a particular client. (eg: State can be maintained per session by declaring a variable)

PerCall : This is used to create a new instance for every call from the client whether same client or different. (eg: No state can be maintained as every time a new instance of the service is created)

Single : This is used to create only one instance of the service and the same instance is used for all the client request. (eg: Global state can be maintained but this will be applicable for all clients)


| Alert Moderator 

Comments or Responses

Posted by: Kothaamsi on: 1/10/2011 | Points: 10
[ServiceBehavior] Attribute Contorls Runtime aspects of the service such as instancing mode,concurrency mode...

Login to post response