I have some logic as part of Session_Start method in Global.asax.cs file. the logic loading some information from the database to session variable so all other Controller actions can use them. Everything if working fine until the session expire.
Since i am using Angular (SPA), users actions not goes to the server frequently so the session can just expire after 20 minutes of "server inactivity" (Its not inactivity of the user because he it working on the client side).
Once he want to perform an action that needs to execute a MVC controller action, the controller constructor doesn't find the information on the cache and throws an error.
I expected that the Session_Start will triggered before invoking the controller contractor but the Sesion_Start event not firing at all because i am not assigning information to the session variables, i need only to read them but they are not available.
i tried to assign a dummy data to the session in order to fire the Session_Start event but i can do so only from the controller action but i need the session_start event will be executed BEFORE the Controller constructor.
Is there a way to trigger Session_Start on EVERY server request when the session is not exist (expired)? Is there an option to fire it before the controller constructor?
the problem is that i can not do so from Application_BeginRequest() for example because sessions can not be accessed or use at that scope.
*** This problematic behavior happens only in production. on dev the session_start always fire. i understand its "by design" so it a bit hard to reproduce **