ASP.NET session is NULL despite a IRequireSessionState/IReadOnlySessionState handler? -


I'm looking at a strange situation.

Within the Global.asax method, I have the following code:

  Protected Zero Application_AcquireRequestState (Object Sender, EventArgs e) {If (! (Reference! Handler is IRequiresSessionState | | Context.Handler is IReadOnlySessionState)) // No session - no validity. Return; do something(); }  

DoSomething () method calls a NullReferenceException and it is quite easy that it can be the only place that is Ho HttpContext.Current.Session was empty.

How can this be?

At that time HttpContext.Current.Session might be OK. The incident is firing at that point where there is no guarantee that the session is going to be happening that it has been gone at this time for one reason you hooked the incident Because you are providing custom modules to implement your own session object. It will happen that such a custom module sets the session.

If you want to use session object, then you should use the PostAquireRequestState event.


Comments

Popular posts from this blog

MySql variables and php -

c# - How can I find out if there are windows above a control? -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -