问题
prompt please how can I use session in self hosted WCF? I need to implement ASP.NET like sessions (client identification and possibly data sharing). Is there any native way to do so in WCF or I have to implement this behavior manually (sending some unique value with each request and storing them in some sessionID store)? Thanks in advance. P.S. Sorry for poor English.
回答1:
You can have sessions in self-hosted WCF, but you'll need to use a binding which has session support. WSHttpBinding, NetTcpBinding and NetNamedPipeBindings all support sessions, as well as other combination of binding elements in custom bindings. You won't be able to use sessions in a BasicHttpBinding, for example, since you won't have the underlying ASP.NET session object it can take advantage of.
来源:https://stackoverflow.com/questions/6172992/sessions-in-self-hosted-wcf-services