【发布时间】:2015-10-05 07:19:19
【问题描述】:
实际上,我们使用 ASP.NET 4.5 (VS 2013) 并希望将 Global.asax.cs 替换为来自 OWIN 规范的新 Startup.cs 文件。
我们以这种方式使用 Application_Start 和 Application_End 处理程序记录应用程序的开始和结束:
protected void Application_Start(object sender, EventArgs e)
{
_log.Info("The app starts.");
}
protected void Application_End(object sender, EventArgs e)
{
_log.Info("The app ends.");
}
但是,据我所知,新的 Startup.cs 文件中没有此类处理程序。所以,我的问题是 - 我们该怎么做?
【问题讨论】:
-
您已经知道应用程序何时启动,因为 Startup.cs 正在执行。对于应用程序结束事件,请查看此答案:stackoverflow.com/questions/27444924/…
-
它有效。谢谢。您是否知道如何处理 Session_Start 和 Session_End?
-
好的。如果你把你的答案写成普通帖子,我会检查出来的。
-
好吧,不过我不知道会话事件。