什么实际上导致在session_start被称为?被称为、session_start

2023-09-03 04:50:39 作者:被淹死的鱼

在一个小的演示应用程序,我建设我把code来初始化Global.Session_Start()事件数据库。不过,我注意到这个事件,当我通过在开发服务器上调试应用程序快到不火(没有测试它在其他地方还没有)。

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 when I'm running through the app in the debugger on the development server (haven't tested it anywhere else yet).

问题1:怎么办?什么时候在session_start()实际上被调用?我假设它是在会话开始时,但不应该请求的每一个新的序列开始导致会话自动启动?当然,一个会议应开始,每当我与F5运行,因此它为什么不能。

Question 1: What gives? When does Session_Start() actually get called? I assume it is when the session starts but shouldn't the beginning of every new sequence of requests cause a session to start automatically? Certainly a session should start whenever I run with F5 so why doesn't it.

问2:有没有更好的地方,code初始化数据库应该去?我宁愿不把它在Application_Start方法,因为它并不总是得到调试时调用。

Question 2: Is there a better place where the code to initialize the database should go? i would rather not put it in the Application_Start method, since it does not always get called when debugging.

PS。通过初始化数据库中,我不是说我开到SqlServer的一个连接,并把它打开,直到永远。我使用了db4o和我开个pre-建立数据库文件。就像我说的,这只是一个演示应用程序,我不担心资源管理不善或类似的东西。

PS. By initialize database I do not mean I open a connection to SqlServer and leave it open forever. I am using db4o and I open a pre-built database file. Like I said this is just a demo application, I'm not worried about poor resource management or anything like that.

推荐答案

我不完全确定一个会话开始,直到你访问会话对象。否则,它会像不必要的开销火了不需要的会话。

I'm not entirely sure that a session "starts" until you access the Session object. Otherwise it would seem like unnecessary overhead to fire up an unneeded session.