What actually causes Session_Start to be called?

前端 未结 4 1324
执笔经年
执笔经年 2021-01-17 19:45

In a little demo application that I\'m building I put code to initialize the database in the Global.Session_Start() event. However, I notice that this event does not fire w

4条回答
  •  甜味超标
    2021-01-17 20:19

    I know this is an old post but maybe this will help somebody:

    The session_start doesn't fire unless you are actually reading or writing to the session object.

    If you want to utilize the session_start event but don't need to use the session store at all, you can add the following to the page directive of your landing pages:

    <%@ Page EnableSessionState="ReadOnly" %>
    

    This will cause the session_start event to fire without you having to store anything in the session object.

提交回复
热议问题