WCF sessions or pass username/password per call?

前端 未结 3 859
暗喜
暗喜 2021-01-31 12:05

For an enterprise type WCF service, where potentially 10K\'s of thousands of clients will be authenticating and sending data to central servers, what is \'best\' practice when i

相关标签:
3条回答
  • 2021-01-31 12:17

    If you host the service within IIS, you can still use the session that is from ASP.NET by enabling aspnetcompatibility for the service behaviour.

    0 讨论(0)
  • 2021-01-31 12:41

    WCF does support sessions yes; but they are not like ASP.NET sessions. Sessions are there to deliver messages in order (and other bits and bobs), they are not there to add shared storage between calls.

    For authenticated service calls you should send your authentication details every time; security is applied on a per message basis.

    0 讨论(0)
  • 2021-01-31 12:44

    As blowdart mentioned, WCF Sessions are not the same as ASP.NET Sessions. You can read up on them here: http://msdn.microsoft.com/en-us/library/ms733040.aspx. Before you roll your own security, you'll want to get familiar with what WCF gives you out-of-the-box: http://msdn.microsoft.com/en-us/library/ms734736.aspx. They may get you close to your goal without writing a lot of code. Specifically, check out How to: Create a Secure Session. With secure sessions, the Client and Server cache credentials so you don't have to fully authenticate with each request. By default, you'll lose a secure session if the web server recycles. If you want a secure session that lasts through a recycle, you'll want to look at How to: Create a Stateful Security Context Token for a Secure Session.

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