ASP.NET MVC: access session data in Session_End or in case

I have already seen a similar question that was posted here . I have essentially the same question, but with a slight twist.

I am trying to access the session information from the Session_End method, but the HttpContext is null by the time I get there, so I find no real way to get to it; it's almost the same as it was already completely removed by the time Session_End started.

The solution in a related question says that I can use the this.Sessionsession information that I need to refer to the variable HttpApplication.Sessionfrom the HttpApplication class inherited by Global. But in my application, we redefined the Session variable in Global to look like this:

    public new static HttpSessionState Session
    {
        get
        {
            return HttpContext.Current.ApplicationInstance.Session;
        }
    }

So, for me, referring to this. The session will try to get information from the HttpContext, which is null.

So, I have 2 questions. Firstly, is there an event that fires before Session_End, but before the session data is cleared? And secondly, if there is no answer to the first question, is there another way to access this data from Session_End?

Thank.

+3
source share
1 answer

, session_end , in_proc: - , . , , , HttpModule. :

http://www.codeproject.com/KB/aspnet/SessionEndStatePersister.aspx

0

Source: https://habr.com/ru/post/1779271/


All Articles