views:

226

answers:

2

I read two MSDN articles on Session state modes in ASP .Net. 1 and 2.

Both articles shows that 'In Process' session state mode is the only mode that supports the Session_OnEnd event. If the session state Mode is StateServer or SQLServer, then the Session_OnEnd event in the Global.asax file is ignored. If the session state Mode is set to Custom, then support for the Session_OnEnd event is determined by the custom session-state store provider.

Can anyone please give me any reason why it will ignore Session_OnEnd event for StateServer or SQLServer modes?

+1  A: 

StateServer and SQL Server modes are running in a configuration where they could be servicing N number of clients in a load balancing scenario and would have to maintain this list and send out messages across process/machine to signal the Session_OnEnd. InProcess knows that Session is managed within the same process as the application so sending the callback to a single listener is straightforward and inherent to the .NET Framework. If you don't like this you could write your own handler, but be aware of the cavaets.

Nissan Fan
+1  A: 

I think that performance is the main issue. In all but the InProc mode, there are several Webservers responding to requests and 1 Server (Might be clustered SQL) handling the state.

Now, who would be responsible for handling the timeout? It would have to be the State server, but we want to burden that server as little as possible. And it would require the state server to Push data out to a (random) webserver, for everything else it is Polled. I doubt that currently the State server even keep a list of the Webservers, they don't need to. So, just for the SeesionEnd event, it would be necessary to add a complex system for administration an monitoring of WebServers.
Add to that the complexity of tracking whether the selected server did indeed complete the event and it all becomes very unattractive.

Henk Holterman
So from your answer and Nissan Fan's answer it is clear that .Net Framework have not implemented due to performence and complexity involved.
Neil