如何处理 ASP.NET 5 中以前的全局事件处理程序?
How to handle former global event handlers in ASP.NET 5?
实际上,我们使用 ASP.NET 4.5 (VS 2013) 并希望用来自 OWIN 规范的新 Startup.cs 文件替换 Global.asax.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 正在执行。对于 Application_End
事件,请查看此答案:Is there Application_End from Global.asax in Owin?
实际上,我们使用 ASP.NET 4.5 (VS 2013) 并希望用来自 OWIN 规范的新 Startup.cs 文件替换 Global.asax.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 正在执行。对于 Application_End
事件,请查看此答案:Is there Application_End from Global.asax in Owin?