Session_OnEnd or Session_End events in global.asax won't fire if you store ASP.NET sessions out of proc (in State Server or SQL Server)

This is an overlooked behavior which may break your ASP.NET application if you are using Session_OnEnd or Session_End events in Global.asax. Here is a snippet from related article from MSDN:

The Session_OnEnd event is only supported when the session-state HttpSessionState.Mode property value is InProc, which is the default. If the session-state Mode is set to StateServer or SQLServer, then the Session_OnEnd event in the Global.asax file is ignored. If the session state Mode property value is Custom, then support for the Session_OnEnd event is determined by the custom session-state store provider.

So, please pay attention to this change if you are planning to move your sessions from InProc to State Server or SQL Server. If you have code in Session_End or Session_OnEnd methods in Global.asax then you may need to find an alternative way to call them as these methods will be ignored after moving sessions to OutProc.

Reference:

SessionStateModule.End Event
https://msdn.microsoft.com/en-us/library/system.web.sessionstate.sessionstatemodule.end.aspx

Applies To:

All ASP.NET versions

--
AMB