How to recognize Session_OnEnd event due to application termination in MVC application

In my ASP.NET MVC4 application, I have Session_OnEnd and Application_End events. When the application completes the Session_OnEnd calls that are called first after the Application_End call. Is there a way to find out in the Session_OnEnd event that this is happening due to the end of the application?


source to share

1 answer

During Session_End, there is no way to know the reason for the event. If your logic is to persist data, can you cache it somewhere (with an expiration date) and pick it up in Application_End?

So, if it's an Application_End script, fetching the cached data will do whatever you need it to.

Otherwise, the cache expires after "x" time and no harm.

Caching Ending in ASP.NET:



All Articles