在两个 WCF 不同服务之间共享 ASP.NET 会话状态

发布于 2024-08-25 06:50:41 字数 268 浏览 5 评论 0原文

我有两个配置了 ASP.NET 兼容模式的 WCF 服务,以允许它们使用 ASP.NET 会话状态。问题如下:

1.- 对第一个服务的调用在 ASP.NET 会话状态中存储一个值。 2.- 对第一个服务的第二次调用可以读取该值。

但是...

3.- 对第二个服务的调用无法读取 ASP.NET 会话状态值。

ASP.NET 会话状态似乎不在两个 WCF 服务之间共享。

有没有办法在两个 WCF 服务之间共享 ASP.NET 会话状态?

I have two WCF services configured with ASP.NET compatible mode to allow them to use ASP.NET session state. The problem is as follows:

1.- A call to the first service stores a value in the ASP.NET session state.
2.- A second call to the first service can read that value.

but...

3.- A call to the second service can't read the ASP.NET session state value.

It seems that the ASP.NET session state is not shared between the two WCF services.

Is there a way to share ASP.NET Session state between two WCF Services?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

↘人皮目录ツ 2024-09-01 06:50:41

如果这两个服务共享数据库,您可以在那里实现会话存储。您将能够在不同的服务或应用程序之间共享信息。

If the 2 services share the database you can implement your session storage there. You would be able in to share information among different services or apps.

心清如水 2024-09-01 06:50:41

这两个调用将生成两个不同的会话,所以答案是否定的。您可能需要找到一些自定义方法来处理此问题。

一般来说,服务调用应该是原子的,并且不应该以这种方式依赖于会话 - 如果您可以使会话根本不被使用,那么这是最好的解决方案。

The two calls will generate two different sessions, so the answer is kinda no. You may need to find some custom way to handle this.

In general, service calls should be atomic and shouldn't be relying on the session in this way - if you can make it so that session is not used at all, then this is the best solution.

深白境迁sunset 2024-09-01 06:50:41

也许这个场景需要的是实现一个持久的服务来保持调用之间的状态。第二个服务可以使用代理类来查询第一个服务的会话状态。我不确定为什么需要这样做,但如果有帮助,请查看此链接:
https://www.microsoftpressstore.com/articles/article。 aspx?p=2228448&seqNum=3

Maybe what is needed for this scenario is to Implement a durable service to keep alive a state between calls. A proxy class could be used for the 2nd service to query the Session state of the first one. I m not sure why it is required to do that but if it is helpful, plz have a look at this link:
https://www.microsoftpressstore.com/articles/article.aspx?p=2228448&seqNum=3

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文