問(wèn)題描述
我想弄清楚如何獲取和分離 sql??server 為 stateserver 返回的 appid 和 sessionid.我需要在我的 web 應(yīng)用程序中獲取此信息,但除了讀取信息之外,我無(wú)法訪問(wèn) 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 列.鏈接發(fā)生在 ASPStateTempSessions 的 SessionId 字段中,該字段不僅僅存儲(chǔ)會(huì)話 ID.它存儲(chǔ)附加了應(yīng)用程序 ID 的會(huì)話 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 表中有這個(gè)值:
so i have this value in the AspStateTempApplications table:
appid appname
-796116323 /w3svc/*/root/fsco*tbsc
我已經(jīng)在會(huì)話表中確定了我的會(huì)話信息與轉(zhuǎn)換后的 appid 嗎?
i have identified in the session table my session info with the appid converted?
sessionid
cp5p2trw5navwnsgmhdzctnn2341447f
后面的部分:2341447f 應(yīng)該對(duì)應(yīng)于 -796116323 但如果我運(yùn)行一個(gè)十六進(jìn)制轉(zhuǎn)換函數(shù),它要么在負(fù)號(hào)上顯示 barfs,要么使用在線轉(zhuǎn)換器給我錯(cuò)誤的值.我怎樣才能得到那個(gè)值,我想查詢會(huì)話值
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
我在這里遺漏了什么......看起來(lái)很簡(jiǎn)單
what am i missing here.. it seems straightforward
推薦答案
可以使用
SUBSTRING(a.SessionId, 25, 8) AS AppIDHex,
并將 AppId 轉(zhuǎn)換為 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/
這篇關(guān)于sqlstateserver appid vb.net的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!