获得在ASP.Net会话ID [英] get session ID in ASP.Net

查看:162
本文介绍了获得在ASP.Net会话ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能得到所有的当前会话ID的?

how can I get IDs of all current sessions?

推荐答案

要获取会话ID,这样做:

To get the session id, do this:

// In a user control or page
string sessionId = this.Session.SessionID; 

// In a normal class, running in a asp.net app.
string sessionId = System.Web.HttpContext.Current.Session.SessionID;

您不应该需要:


  • 请任何数据表或循环任何

  • SQL Server用于会话状态

  • 手柄在session_start和Session_End中

在一个Cookie的情况下,当你访问会话对象首次创建的会话ID。这应该没有多大关系,因为一时访问SessionID属性,会话对象进行访问。

In a cookieless scenario, the session id is created when you access the Session object for the first time. This shouldn't matter much, because the moment you access the SessionID property, the session object is accessed.

有关更多信息,看看这个:

For more info, look into this:

<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.sessionid.aspx\">http://msdn.microsoft.com/en-us/library/system.web.sessionstate.httpsessionstate.sessionid.aspx

请注意:MSDN的例子已经写的猴子

Note: The msdn examples have been written by monkeys.

这篇关于获得在ASP.Net会话ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆