Are WCF services stateless by default?

前端 未结 2 521
一个人的身影
一个人的身影 2020-12-19 03:14

I\'ve got a simple WCF service that lets clients/consumer applications log in by providing a username and password. If both the username and password are correct, the WCF se

相关标签:
2条回答
  • 2020-12-19 03:23

    Per-call services are the Windows Communication Foundation default instantiation mode. So, by default, WCF services do not maintain state. As Marc stated, there are potential problems with saving state in WCF services. I strongly suggest heeding his advice.

    This article describes various ways to handle instance management in WCF, including how to maintain state like you're asking for.

    Chapter 4 of Juval Lowy's excellent Programming WCF Services (link) goes into much greater detail.

    0 讨论(0)
  • 2020-12-19 03:34

    They are stateless by default and I would highly recommended keeping it that way if possible. However if for some reason you are unable to, you can enable state.

    You have to use wsHttpBinding or wsDualHttpBinding and then set the SessionMode of the ServiceContract (MSDN link) to allowed or required. goes into much greater detail.

    0 讨论(0)
提交回复
热议问题