The lifetime of an instance of a WCF service?

后端 未结 4 1061
南方客
南方客 2021-01-05 12:03

in the process of creating a WCF service I ran into a term that\'s new to me. Basically when specifying the InstanceContextMode I have a few options, including;

4条回答
  •  無奈伤痛
    2021-01-05 12:20

    Yes, sharing the service instance means that there's only one instance created by the server, shared between requests.

    In particular, the constructor of the service object will be called once, when the instance is created. This can be important for example if you use some form of authentication with impersonating the context's identity (shared instances could potentially require some extra work to handle such case).

提交回复
热议问题