是WCF服务在默认情况下无状态?

编程入门 行业动态 更新时间:2024-10-27 00:26:15
本文介绍了是WCF服务在默认情况下无状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个简单的WCF服务,可以让客户端/消费类应用提供了一个用户名和密码登录。如果两个用户名和密码都正确,WCF服务向客户端提供一个GUID。 GUID和用户名,然后保存为WCF服务中的一个键/值对。从这里开始,客户端发送的GUID与作为一种识别手段的每个请求。

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 service provides the client with a GUID. The GUID and the username are then stored as a key/value pair within the WCF service. From here onwards, the client sends their GUID with every request as a means of identification.

由于我存储在一个词典/ HashMap中的键/值对,这如果WCF服务是有状态的做法只会工作。问题是,他们是否为默认的状态或者是有什么我需要做的,使他们以这种方式表现?

Since I'm storing the key/value pair in a Dictionary/Hashmap, this approach would only work if the WCF service is stateful. Question is, are they stateful by default or is there something I have to do to make them behave in that manner?

推荐答案

每-call服务是Windows Communication Foundation的默认实例化模式。因此,在默认情况下,WCF服务不维护状态。正如马克指​​出,有与WCF服务节能状态的潜在问题。我强烈建议听取他的意见。

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.

这的文章,介绍了各种方式来处理实例管理在WCF中,包括如何保持状态,就像你问的。

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

的Juval洛伊出色的第4章编程WCF服务(链接)进入更多的细节。

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

更多推荐

是WCF服务在默认情况下无状态?

本文发布于:2023-11-09 03:11:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571235.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:情况下   状态   WCF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!