473,626 Members | 3,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session_End and SqlServer Session Mode

I realized that when SqlServer mode is used for session management
Session_End event is not fired in global.asax.
What can I do if I want to do something when a user's session end?

Thanks
Nov 18 '05 #1
8 8404
well isn't that the whole point of using sqlserver mode? that you don't want
to be affected by session end events? the session end event you are hoping
to target is only supported in inproc mode when the session data is stored
in the asp.net worker process.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"karahan celikel" <NO************ *******@hotmail .com> wrote in message
news:eb******** ******@TK2MSFTN GP11.phx.gbl...
I realized that when SqlServer mode is used for session management
Session_End event is not fired in global.asax.
What can I do if I want to do something when a user's session end?

Thanks

Nov 18 '05 #2
Hello Karahan,

Thanks for posting in the group.

I agree with Alvin that Session_End event is supported only in InProc mode.

Here is a quick summary of the major things you need to know about picking
asp.net session state mode:

Storage location
----------------
InProc - session kept as live objects in web server (aspnet_wp.exe)

StateServer - session serialized and stored in memory in a separate process
(aspnet_state.e xe). State Server can run on another machine

SQLServer - session serialized and stored in SQL server

Performance
------------
InProc - Fastest, but the more session data, the more memory is consumed on
the web server, and that can affect performance.

StateServer - When storing data of basic types (e.g. string, integer, etc),
in one test environment it's 15% slower than InProc. However, the cost of
serialization/deserialization can affect performance if you're storing lots
of objects. Have to do performance testing for your own scenario.

SQLServer - When storing data of basic types (e.g. string, integer, etc),
in one test environment it's 25% slower than InProc. Same warning about
serialization as in StateServer.
Robustness
-----------
InProc - Session state will be lost if the worker process (aspnet_wp.exe)
recycles, or if the appdomain restarts. It's because session state is
stored in the memory space of an appdomain. Read doc on when such events
will happen.

StateServer - Solve the session state loss problem in InProc mode. Allows
a webfarm to store session on a central server. Single point of failure at
the State Server.

SQLServer - Similar to StateServer. Moreover, session state data can
survive a SQL server restart after you've followed instructions in KB
311029.

Caveats
--------
InProc - It won't work in web garden mode, because in that mode multiple
aspnet_wp.exe will be running on the same machine. Switch to StateServer
or SQLServer when using web garden. Also Session_End event is supported
only in InProc mode.

StateServer - In a web farm, make sure you have the same <machineKey> in
all your web servers. See KB 313091 on how to do it. Also, make sure your
objects are serializable. See KB 312112 for details.

SQLServer - If you specify integrated security in the connection string
(e.g. "trusted_connec tion=true", or "integrated security=sspi") , it won't
work if you also turn on impersonation in asp.net. Unfortunately, this bug
isn't reported in KB yet. (There is a QFE fix for it.) Also, make sure
your objects are serializable. See KB 312112 for details.

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 18 '05 #3
Thanks Alvin and Yan-Hong for your replies.

but isn't it weird that session_start is fired but not session_end?

"Yan-Hong Huang[MSFT]" <yh*****@online .microsoft.com> wrote in message
news:Qt******** ******@cpmsftng xa07.phx.gbl...
Hello Karahan,

Thanks for posting in the group.

I agree with Alvin that Session_End event is supported only in InProc mode.
Here is a quick summary of the major things you need to know about picking
asp.net session state mode:

Storage location
----------------
InProc - session kept as live objects in web server (aspnet_wp.exe)

StateServer - session serialized and stored in memory in a separate process (aspnet_state.e xe). State Server can run on another machine

SQLServer - session serialized and stored in SQL server

Performance
------------
InProc - Fastest, but the more session data, the more memory is consumed on the web server, and that can affect performance.

StateServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 15% slower than InProc. However, the cost of
serialization/deserialization can affect performance if you're storing lots of objects. Have to do performance testing for your own scenario.

SQLServer - When storing data of basic types (e.g. string, integer, etc),
in one test environment it's 25% slower than InProc. Same warning about
serialization as in StateServer.
Robustness
-----------
InProc - Session state will be lost if the worker process (aspnet_wp.exe)
recycles, or if the appdomain restarts. It's because session state is
stored in the memory space of an appdomain. Read doc on when such events
will happen.

StateServer - Solve the session state loss problem in InProc mode. Allows
a webfarm to store session on a central server. Single point of failure at the State Server.

SQLServer - Similar to StateServer. Moreover, session state data can
survive a SQL server restart after you've followed instructions in KB
311029.

Caveats
--------
InProc - It won't work in web garden mode, because in that mode multiple
aspnet_wp.exe will be running on the same machine. Switch to StateServer
or SQLServer when using web garden. Also Session_End event is supported
only in InProc mode.

StateServer - In a web farm, make sure you have the same <machineKey> in
all your web servers. See KB 313091 on how to do it. Also, make sure your objects are serializable. See KB 312112 for details.

SQLServer - If you specify integrated security in the connection string
(e.g. "trusted_connec tion=true", or "integrated security=sspi") , it won't
work if you also turn on impersonation in asp.net. Unfortunately, this bug isn't reported in KB yet. (There is a QFE fix for it.) Also, make sure
your objects are serializable. See KB 312112 for details.

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 18 '05 #4
What do you want to do ?

Sometimes it's possible to differ this processing (for example using a SQL
Server job that performs some cleanup).

Patrice

--

"karahan celikel" <NO************ *******@hotmail .com> a crit dans le
message de news:eb******** ******@TK2MSFTN GP11.phx.gbl...
I realized that when SqlServer mode is used for session management
Session_End event is not fired in global.asax.
What can I do if I want to do something when a user's session end?

Thanks


Nov 18 '05 #5
No not really, these events aren't necessarily paired. It's a common
misunderstandin g on the part of developers. Here's a link to an explanation
of the session end event and when it fires. That may help clear up some of
your confusion.
http://www.developersdex.com/gurus/articles/746.asp

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Karahan Celikel" <NO************ *******@hotmail .com> wrote in message
news:ub******** ******@TK2MSFTN GP10.phx.gbl...
Thanks Alvin and Yan-Hong for your replies.

but isn't it weird that session_start is fired but not session_end?

"Yan-Hong Huang[MSFT]" <yh*****@online .microsoft.com> wrote in message
news:Qt******** ******@cpmsftng xa07.phx.gbl...
Hello Karahan,

Thanks for posting in the group.

I agree with Alvin that Session_End event is supported only in InProc

mode.

Here is a quick summary of the major things you need to know about picking asp.net session state mode:

Storage location
----------------
InProc - session kept as live objects in web server (aspnet_wp.exe)

StateServer - session serialized and stored in memory in a separate

process
(aspnet_state.e xe). State Server can run on another machine

SQLServer - session serialized and stored in SQL server

Performance
------------
InProc - Fastest, but the more session data, the more memory is consumed

on
the web server, and that can affect performance.

StateServer - When storing data of basic types (e.g. string, integer,

etc),
in one test environment it's 15% slower than InProc. However, the cost of serialization/deserialization can affect performance if you're storing

lots
of objects. Have to do performance testing for your own scenario.

SQLServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 25% slower than InProc. Same warning about
serialization as in StateServer.
Robustness
-----------
InProc - Session state will be lost if the worker process (aspnet_wp.exe) recycles, or if the appdomain restarts. It's because session state is
stored in the memory space of an appdomain. Read doc on when such events will happen.

StateServer - Solve the session state loss problem in InProc mode. Allows a webfarm to store session on a central server. Single point of failure

at
the State Server.

SQLServer - Similar to StateServer. Moreover, session state data can
survive a SQL server restart after you've followed instructions in KB
311029.

Caveats
--------
InProc - It won't work in web garden mode, because in that mode multiple
aspnet_wp.exe will be running on the same machine. Switch to StateServer or SQLServer when using web garden. Also Session_End event is supported
only in InProc mode.

StateServer - In a web farm, make sure you have the same <machineKey> in
all your web servers. See KB 313091 on how to do it. Also, make sure

your
objects are serializable. See KB 312112 for details.

SQLServer - If you specify integrated security in the connection string
(e.g. "trusted_connec tion=true", or "integrated security=sspi") , it won't work if you also turn on impersonation in asp.net. Unfortunately, this

bug
isn't reported in KB yet. (There is a QFE fix for it.) Also, make sure
your objects are serializable. See KB 312112 for details.

Does that answer your question?

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no

rights.


Nov 18 '05 #6
As you said, I need to do some clean-up and also log user activities.
But after thinking about it , I realized that there may be no point to fire
session_end event as Alvin pointed out.
SqlServer mode is used in web farm scenarios with more than one web
application. So it would be ambiguous that which web application will handle
the session_end. event and does clean-up etc. But it would be a great
feature if we could define which web app will be responsible for that event
in web.config file.

and I also would like to have a transparent state management without
considering caveats of each one e.g serialization, same machine keys,
session_end , integrated security.

Anyway, I decided to do the cleanup in sql server side even though that is
somewhat bad for the object orientation.
Thanks

"Patrice Scribe" <no****@nowhere .com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
What do you want to do ?

Sometimes it's possible to differ this processing (for example using a SQL
Server job that performs some cleanup).

Patrice

--

"karahan celikel" <NO************ *******@hotmail .com> a crit dans le
message de news:eb******** ******@TK2MSFTN GP11.phx.gbl...
I realized that when SqlServer mode is used for session management
Session_End event is not fired in global.asax.
What can I do if I want to do something when a user's session end?

Thanks

Nov 18 '05 #7

Yeah. That is really a good article and explains the behavior. :)

Karahan, do you have any more concerns on it?

Have a good day.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 18 '05 #8
As you said, I need to do some clean-up and also log user activities.
But after thinking about it , I realized that there may be no point to fire
session_end event as Alvin pointed out.
SqlServer mode is used in web farm scenarios with more than one web
application. So it would be ambiguous that which web application will handle
the session_end. event and does clean-up etc. But it would be a great
feature if we could define which web app will be responsible for that event
in web.config file.

and I also would like to have a transparent state management without
considering caveats of each one e.g serialization, same machine keys,
session_end , integrated security.

Anyway, I decided to do the cleanup in sql server side even though that is
somewhat bad for the object orientation.
Thanks
"Patrice Scribe" <no****@nowhere .com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
What do you want to do ?

Sometimes it's possible to differ this processing (for example using a SQL
Server job that performs some cleanup).

Patrice

--

"karahan celikel" <NO************ *******@hotmail .com> a crit dans le
message de news:eb******** ******@TK2MSFTN GP11.phx.gbl...
I realized that when SqlServer mode is used for session management
Session_End event is not fired in global.asax.
What can I do if I want to do something when a user's session end?

Thanks

Nov 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1343
by: A | last post by:
Hi, does anybody know how (if possible) to change the database name for the session database (which is ASPState)? My problem is that our website/sqlserverdb is hosted by an isp, and we are not alone (on the server) Regards,
4
3992
by: John Q. Smith | last post by:
I'm trying to find out some of the details behind OOP state management with SQL Server. For instance - how long does the session object live on any server? Is it created and destoyed with each page request? - will each reading of a session variable cause a round trip to the DB server? or does the complete session live within the HttpContext object? - when asp.net session state is enabled (in any mode), after a session has been created,...
1
2680
by: Julie Barnet | last post by:
Hi, I am having a problem with my session state through sql server. This used to work, then all of a sudden (the only change was setting up replication in the sqlserver database) it stopped working. I ran uninstallsqlstate.sql after stopping w3svc and then restarted the w3svc and rean installsqlstate.sql. This works fine on my machine and my session variables work again....but I'm an administrator on the database. I go to another...
2
1822
by: Dave Wright | last post by:
Hi, We have implemented a IIS NLB farm and would like to know if a SQL Session database can be used to host multiple sites? As the entry in web.config does not allow a database name to be specified it would mean either multiple instances / servers if more than 1 site needed to store session in a SQL database. As such I am guessing it will work but I would like to confirm this. Any info would be great
0
1018
by: Jeff Carver | last post by:
I've been experimenting with SQLServer session state, and I'm puzzled by something. When I use Session.SessionID to display the session ID, I get a 24-character string, e.g.: ayzuglzyznc4o4eplcu1h2bj The corresponding database value (ASPState.ASPStateTempSessions.SessionID) is a 32-character string which equates to the 24-character Session.SessionID value plus "00000001":
4
2153
by: Lucas Tam | last post by:
If I use Out of Proc mode for sessions - do I get all of the in-Proc session features, but it's just slower? Also, if I upgrade the DLLs on the server side, will I lose Out of Proc sessions? Thanks. -- Lucas Tam (REMOVEnntp@rogers.com)
0
1241
by: Kevin Jackson | last post by:
We are running a ASP.NET 1.1 web app on Windows Server 2003 SP1. We are using IIS 6.0 native mode and .NET 1.1 SP1 is installed. We have 3 web apps in our web farm. We are using SQLServer session state and have our machinekeys matched. We just launched a few days ago. We did an iisreset this morning on all 3 and tonight when things settled down I noticed we had 30 SPIDs still connected to the web apps. These SPIDs were all...
0
2901
by: =?Utf-8?B?QmFsYWpp?= | last post by:
The issue description is as follows: Environment Windows Server 2003 SP2 Framework 1.1 Framework 2.0 SqlServer 2000 Description: The Web server hosts both Framework 1.1 and 2.0 applications. The application runs Framework 1.1 and works as expected in “InProc” Session mode.
2
1011
by: gnewsgroup | last post by:
For asp.net web application, I had thought that using SQL Server Session State management would imply that all session objects be stored in SQL Server database ASPState. But when I look into it, I notice that only stuffs related to SessionID are stored in the database. None of my session objects such as Session.Contents, Session.Contents can be found in the database. So, is it the case that session objects are really stored in memory
0
8272
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8205
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8713
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8370
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4208
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2632
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1516
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.