Question

I'm looking for a good way to visualize ASP.NET session state data stored in SQL server, preferably without creating a throwaway .aspx page. Is there a good way to get a list of the keys (and serialized data, if possible) directly from SQL server?

Ideally, I'd like to run some T-SQL commands directly against the database to get a list of session keys that have been stored for a given session ID. It would be nice to see the serialized data for each key as well.

Was it helpful?

Solution

Can you elaborate slightly, is there no reference to a HttpContext available (You can use this from backend code as well FYI), which prevents you from utilizing the built in serialization and keys dictionary?

EDIT, in response to your update. I believe the ASPState database creates and destroys temporary tables as needed, it does not have permanent tables you can query, take a look at the stored procedures and you should find one along the lines of "TempGetItem", you can either use this sproc directly, or examine its source for more insight.

OTHER TIPS

When you run asp.net application with sql server session mode, it creates two tables, dbo.ASPStateTempApplications and dbo.ASPStateTempSessions. You can find your application from first table and use it to query open sessions from second table. The ASPStateTempSessions table stores two columns SessionDataShort and SessionDataLong. All session information is binary. You need to know object types being stored in session if you want to deserialize them back again and view the contents.

I have tried this recently and it works fine. In fact, for a complex application it is worth having some tools to view and parse session data to make sure we dont store unwanted objects and leave it in database for long - it has potential of slowing things down.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top