How to extract session data from MSSQL using "Sql Server" session state mode

I have confronted with some difficulties: I have a task to extract logged user session data from database to collect statistic information from SPPS 2003 (Sharepoint Portal Server) for analyzing purposes.

Information I need looks ordinary enough: username, datetimes of user log in and log out, etc..

After digging hundreds of articles and docs, I had found out that session object is serialized into database record. It is ok, but I found no decription about where this data can be stored or how can I have access to it.

What can I do with it or what should I read for achieving my object?

 

Thanx.
 

0
Yniil
6/26/2007 1:46:00 PM
asp.net.state-management 8807 articles. 0 followers. Follow

4 Replies
1799 Views

Similar Articles

[PageSpeed] 47
Get it on Google Play
Get it on Apple App Store

HI, Yniil:

To maintain session scope, session-state providers store session information uniquely for each application. This allows multiple ASP.NET applications to use the same data source without running into a conflict if duplicate session identifiers are encountered.

Because session-state store providers store session information uniquely for each application, you must ensure that your data schema, queries, and updates include the application name. For example, the following command might be used to retrieve session data from a database.

SELECT * FROM Sessions
  WHERE SessionID = 'ABC123' AND ApplicationName = 'MyApplication'
I found a solution to share with you but i have not tested it now.  
Serialized data can be saved in database and it is perfect for shopping carts or reletional datasets used on your site etc. Trick is to serialiaze it as array byte and you can save it to database using binary field like image, etc

'''''
Imports System.Runtime.Serialization.Formatters.Binary

'''''

Public Function serializeDatatable(ByVal dt As DataTable) As Byte()
Dim objMemoryStream As MemoryStream
Dim objBinaryFormatter As BinaryFormatter

objMemoryStream = New MemoryStream
objBinaryFormatter = New BinaryFormatter

objBinaryFormatter.Serialize(objMemoryStream, dt)
objMemoryStream.Close()
Return objMemoryStream.ToArray
End Function

 

Public Function deserializeDatatable(ByVal arrByte As Byte()) As DataTable //you can transfer the serialized data field from db to the arrByte
Dim objMemoryStream As MemoryStream
Dim objBinaryFormatter As BinaryFormatter

objMemoryStream = New MemoryStream(arrByte)
objBinaryFormatter = New BinaryFormatter

Dim dt As DataTable = CType(objBinaryFormatter.Deserialize(objMemoryStream), DataTable)
objMemoryStream.Close()
Return dt

 
I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance


 


Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support

If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
0
Rex
6/28/2007 1:26:07 AM

Hi, Rex.

Thank you very much for your response, but I have no idea, where session data in database is stored, though I have ASPState database on my server. I have set "Sql Server" mode in ASP.NET Configuration in tab "State Management" (data source=localhost;Integrated Security=SSPI).

In fact sessions, if set no persistent storage (and sessions are deleted with mssql server reboot), should be stored in tempdb database, where I have "ASPStateTempApplications" and "ASPStateTempSessions" tables. But they are always empty.

Could it be the problem? If yes, how can it be solved?
 

0
Yniil
6/28/2007 3:13:02 PM

HI, Yniil

First, make sure that the SQL Server agent is running as it manages these jobs to maintain the session state in your SQL database.

Second, When you use the default InstallSqlState.sql and UninstallSqlState.sql script files to configure ASP.NET SQL Server mode session state management, note that these files add the ASPStateTempSessions and the ASPStateTempApplications tables to the tempdb database in SQL Server by default. Furthermore, if you restart SQL Server, you lose the session state data that was stored in the ASPStateTempSessions and the ASPStateTempApplications tables.For additional information about how to run alternative scripts to configure persistent SQL Server session state management so that the session data is not lost when you restart the server, click the article number below to view the article in the Microsoft Knowledge Base:

http://support.microsoft.com/kb/311209/EN-US/ HOW TO: Configure ASP.NET for Persistent SQL Server Session State Management
http://support.microsoft.com/kb/317604             HOW TO: Configure SQL Server to Store ASP.NET Session State
 
If i misunderstand you about your question, please feel free to correct me and i will try to help you with more information.

I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance

Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support

If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
0
Rex
6/29/2007 1:34:27 AM

Hi again, Rex!

After some time passed, I realized the fact that I could explore the false direction to solve the problem.

In fact, I have the task to extract user session data to collect statistics. Does these tables store the data I need? Or I am wrong from the beginning?

 

 The information you gave me is very helpful, but it could not solve the problem :(

0
Yniil
8/27/2007 10:34:54 AM
Reply:

Similar Artilces:

Error message
Hello,I have developed an ASP.NET c# application.I have a "Reports" page in which i put the the report's DataTable in a session (to use it later on for paging and sorting).This works on my localhost but on production I get the follwong error:Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic...

Good news for those of you who get "Unable to make the session state request to the session state server." error..
Dear all,Due to the known problem of session variables getting lost if using InProc-server during frequent changes in development, I had to choose between SQL and ASP.NET State server, so I opted for the second. Initially, all fine, but after using it for a few days, I started to get this error: Server Error in '/cv2' Application.Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accep...

Migrating Session "In proc" from "State Server"
Hi all, I am using Asp.net with vb.net I just migrate the session state In proc to State server... but it gives error.... "Unable to serialize the session state. Please note that non-serializable objects or MarshalByRef objects are not permitted when session state mode is 'StateServer' or 'SQLServer'" I just stored Login Name and some other string properties of User is session ... like, Session("UserName") = strUserName or Session("UserType") = strUserType. "strUserName" and "strUserType" both are string. Any idea ? thanks, SajjadPlease Mark as Answer, if the post Solve you...

Unable to use session state server....requires session state server version 2.0 or above.
So, I have Windows 2003 IIS latest service packs running. Its running .NET 2.0 and .NET 1.1 applications in seperate application pools. Just today I applied the following patch to the server. (The server is not running any 3.0 or 3.5 applications or application pools)  Microsoft .NET Framework 3.5 Service Pack 1 and .NET Framework 3.5 Family Update (KB951847) x86 Microsoft .NET Framework 3.5 Service Pack 1 is a full cumulative update that contains many new features building incrementally upon .NET Framework 2.0, 3.0, 3.5, and includes cumulative servicing upda...

"The page requires session state that is no longer available. Either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. Try increa
Hi.. I am making a mobile application using .net framework 2.0. My Application has web farm scenario so for state management I am using Sateserver in my application. My application runs fine if I dont use web farm scenario But in case of web farm scenario it is giving me error "The page requires session state that is no longer available. Either the session has expired, the client did not send a valid session cookie, or the session state history size is too small. Try increasing the history size or session expiry limit." I am not getting why this error is coming ..Though I already h...

Session_End Event in global.asax is not exeuting when the session state mode is state server or sql server
Hi, The code written in global.asax file Session_End()  Method is not executing when the session state mode is state Server Or sqlserver. can any body please suggest me how can i trap the seesion_end Event when the mode is state server.            You cannot.  Only when your session state is set to InProc will that event fire.  This is by design. The other 2 modes represent out of process (and possibly off-box) services that do not have the ability to raise events inside of your app.  Mike Banavige~~~~~~~~~~~~Need a site code s...

how to store data in state server mode of session state
How do I store and retrieve data in state server mode of session state? How do i increase integer in label control when user adds item in shopping cart? for ex (2) items added. when the user adds a third item the label control should say (3) items added. Thank you, Farhan Hi,You do not have to do anything special in your code You can use the Session object in the normal way and need not do anything. ASP .Net handles it behind the scenes.Store your variables using the session object like, Session("Items") = 5  and so onHibrihttp://www.hibri.net...

Session("userCount")=0 in Application_Start
Dear Experts I followed the video tutorial No.2 that demonstrates no of users accessing the website at a given moment. In the global.aspx on Application_Start i have intialized a session variable as follows Session("userCount")=0and am incrementing this in Session_Start event as follows Session("userCount") +=1 When i debug and run the application i get the following error Server Error in '/SessionTest' Applicaiton. Session state is not available in this context (in the Application_Start Event) When i hit the refresh button a couple of times it works. but open another window the cou...

session expires in firefox when using mode="sqlserver" cookieless="false"
hi when i uses mode="sqlserver" and cookieless="false" to store session in the sqlserver2005.  The session expires after first login  when jump to any page(click on any link). At seccond login time it doesn't expire.  but Works fine for IE. any one know the solution, Plz help me.  Thanks in advance....

session.item("fieldName") and session.originalItem("fieldName")
Hi All, What is difference between session.item("fieldName") and session.originalItem("fieldName") ? I don't even difference between session("fieldName) and above specified.   Regards Abdul http://msdn2.microsoft.com/en-us/library/aa140389(office.10).aspx  Regards Mike [MVP - ASP/ASP.NET]My site...

Using SQL Server for Session State Management
Hello, We are implementing session management in a custom database, provided by the following sessionState configuration in web.config: <sessionState mode="SQLServer" stateConnectionString=""    allowCustomSqlDatabase="true"    sqlConnectionString="Data Source=serverName;Database=databaseName;User Id=userName;Password=password"    cookieless="false" timeout="60" /> For reasons to complicated to go into, our company imposes standards on how/where database connection strings get stored. Is there an attribute or method by which I co...

{"Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive." error
Hi. Wonder if anyone can help me out. The above error occurs when I add the statement in below in my web.config. I have tried adding "<add name="Session" type="System.Web.SessionState.SessionStateModule" />" but doesn't seem to resolve the error.  FormsAuthSession is a class that implements IHttpModule. This class is used to make sure that the current request is associated with current login session.Any ideas? <httpModules><add name="FormsAuthSession" type="FormsAuthSession" /> </httpModules> ...

Session on End event if using state server or sql server
The documentation for 'Session_OnEnd' indicates that it not invoked if the session is stored in sql server or state server. Any workarounds to capture Session_OnEnd if the session is maintained in state server or sql server? Thanks in advance. I solved in the following way.The approach is in check for the new / existing session on each request at global.asax.Here is the simple work around private void Application_PreRequestHandlerExecute(Object sender, EventArgs e){        if (Context.Session != null)     &n...

Unable to make the session state request to the session state server.
 Hello,           I’m receiving this error when I put my website on production."Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before men...

Web resources about - How to extract session data from MSSQL using "Sql Server" session state mode - asp.net.state-management

Resources last updated: 12/20/2015 10:27:25 PM