sqlstateserver appid vb.net
我想弄清楚如何获取和分离 sqlserver 为 stateserver 返回的 appid 和 sessionid.我需要在我的 web 应用程序中获取此信息,但除了读取信息之外,我无法访问 sqlserver.
Im trying to figure out how to get and separate the appid and the sessionid that gets returned by sqlserver for stateserver. I need to get this info in my webapp and i do not have access to the sqlserver other than to read the information.
在文档中:奇怪的是,ASPStateTempSessions 表缺少将其链接到 ASPTempStateApplications 的 AppId 列.链接发生在 ASPStateTempSessions 的 SessionId 字段中,该字段不仅仅存储会话 ID.它存储附加了应用程序 ID 的会话 ID.声明
in the docs:Curiously, the ASPStateTempSessions table lacks an AppId column linking it to ASPTempStateApplications. The linkage occurs in ASPStateTempSessions's SessionId field, which doesn't store just session IDs. It stores session IDs with application IDs appended to them. The statement
cmd.Parameters[0].Value = id + _partitionInfo.AppSuffix
所以我在 AspStateTempApplications 表中有这个值:
so i have this value in the AspStateTempApplications table:
appid appname
-796116323 /w3svc/*/root/fsco*tbsc
我已经在会话表中确定了我的会话信息与转换后的 appid 吗?
i have identified in the session table my session info with the appid converted?
sessionid
cp5p2trw5navwnsgmhdzctnn2341447f
后面的部分:2341447f 应该对应于 -796116323 但如果我运行一个十六进制转换函数,它要么在负号上显示 barfs,要么使用在线转换器给我错误的值.我怎样才能得到那个值,我想查询会话值
the portion at the back: 2341447f should correspond to -796116323 but if i run a hexadecimal convert function it either barfs on the negative sign or using online converters gives me the wrong value. how can i get that value, i would like to query session values
我在这里遗漏了什么......看起来很简单
what am i missing here.. it seems straightforward
推荐答案
可以使用
SUBSTRING(a.SessionId, 25, 8) AS AppIDHex,
并将 AppId 转换为 HEX
and convert AppId to HEX
SUBSTRING(sys.fn_varbintohexstr(CONVERT(VarBinary,b.AppId)), 3, 8)
SQL 代码:
SELECT
a.SessionId,
SUBSTRING(a.SessionId, 25, 8) AS AppIDHex,
b.AppId AS AppIDDec,
b.AppName,
DATALENGTH(a.SessionItemLong) AS SessionSize
FROM
dbo.ASPStateTempSessions AS a
LEFT OUTER JOIN
dbo.ASPStateTempApplications AS b
ON
SUBSTRING(a.SessionId, 25, 8) =
SUBSTRING(sys.fn_varbintohexstr(CONVERT(VarBinary,b.AppId)), 3, 8)
https://blogs.msdn.microsoft.com/rextang/2008/01/12/asp-net-checking-session-size-in-sql-server-aspstate-db/
相关文章