简体   繁体   English

Web服务中的会话管理?

[英]session management in web services?

is it possible to manage sessions in web-services? 是否可以管理Web服务中的会话? if yes, how to manage session in it? 如果是,如何管理其中的会话? is it similar to sessions we maintain in JSP or PHP? 它类似于我们在JSP或PHP中维护的会话吗? where does the info about the session will be stored, Client or Server? 关于会话的信息将存储在哪里,客户端还是服务器?

It's possible to use the Session object in .NET inside of a webservice...however I'd say it is bad practice. 可以在Web服务中使用.NET中的Session对象......但是我会说这是不好的做法。 Typically speaking a webservice isn't passed data this way and the data in the service doesn't persist between calls. 通常来说,Web服务不会以这种方式传递数据,并且服务中的数据不会在调用之间持续存在。

Is it java or .net question? 是java还是.net问题?

In .net you can easily use session state on webservice hosting server by setting EnableSession parameter in WebMethod attribute, for example: 在.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;
}

是一篇关于WS-ReliableMessaging的文章,它有会话支持,并且在java和.net开发中都受支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM