c# - 我们如何为 WebHttpBinding WCF REST 服务实现 session 管理?

标签 c# wcf rest

我一直在根据需要使用 webHttpBinding session 模式开发 WCF REST 服务。但我总是收到此错误“契约(Contract)需要 session ,但绑定(bind)‘WebHttpBinding’不支持它或未正确配置为支持它。”任何人都可以说出这是什么原因吗?

最佳答案

引自MSDN forums :

You cannot use WebHttpBinding for session based communication as it doesn't support the concept of sessions. I talked at length about sessions here - http://www.dotnetconsult.co.uk/weblog2/PermaLink,guid,af6e6325-2e30-42e3-acb9-57e1363fa51e.aspx.

WebHttpBinding doesn't support session for the same reason BasicHttpBinding doesn't. If you really must have sessions then you will have to use a binding that supports it. However, PerSession activation is only one way to maintain per client state. Can you not use another mechanism, say passing a session id to the service that you use to wire up your own concept of session?

关于c# - 我们如何为 WebHttpBinding WCF REST 服务实现 session 管理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21257565/

相关文章:

c# - IDataErrorInfo问题

c# - 在 NHibernate 中停止延迟加载或跳过加载属性?无法通过 WCF 序列化代理

c# - 在 WCF 服务和客户端中使用程序集中的接口(interface)和类

javascript - 处理多个并发请求 Express

C# LINQ "inner join"集合

c# - 从 Directory.GetFiles 中排除结果

c# - 如何找到最少数量的公共(public)集

c# - WCF——解决方案架构

java - 微服务之间的通信和使用 REST 的内聚

rest - 使用 Spring Boot 和 Java 8 的非阻塞 REST