Web 服务中的会话管理?

发布于 2024-09-13 20:34:43 字数 85 浏览 3 评论 0原文

是否可以管理网络服务中的会话?如果是,如何管理其中的会话?它与我们在 JSP 或 PHP 中维护的会话类似吗?有关会话的信息将存储在哪里,客户端还是服务器?

is it possible to manage sessions in web-services? if yes, how to manage session in it? is it similar to sessions we maintain in JSP or PHP? where does the info about the session will be stored, Client or Server?

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

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

发布评论

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

评论(3

你曾走过我的故事 2024-09-20 20:34:43

可以在 Web 服务内使用 .NET 中的 Session 对象...但是我认为这是不好的做法。通常来说,Web 服务不会以这种方式传递数据,并且服务中的数据不会在调用之间保留。

It's possible to use the Session object in .NET inside of a webservice...however I'd say it is bad practice. Typically speaking a webservice isn't passed data this way and the data in the service doesn't persist between calls.

深海夜未眠 2024-09-20 20:34:43

是java还是.net的问题?

在 .net 中,您可以通过在 WebMethod 属性中设置 EnableSession 参数轻松使用 Web 服务托管服务器上的会话状态,例如:

[WebMethod(EnableSession = true)]
public bool Login(string login, string password)
{
    // you can use session here so for example log in user
    if(login = "administrator" && password = "secret")
       Session["authorizedUser"] = login;
}

Is it java or .net question?

In .net you can easily use session state on webservice hosting server by setting EnableSession parameter in WebMethod attribute, for example:

[WebMethod(EnableSession = true)]
public bool Login(string login, string password)
{
    // you can use session here so for example log in user
    if(login = "administrator" && password = "secret")
       Session["authorizedUser"] = login;
}
抠脚大汉 2024-09-20 20:34:43

这里是一篇关于 WS-ReliableMessaging 的文章,其中具有会话支持,并且支持 java 和 .net 开发。

Here is an article on WS-ReliableMessaging, which has session support, and is supported on both java and .net development.

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