是否可以在使用 OWIN 的 ASP.NET 应用程序中处理事件?
Is it possible to handle events in ASP.NET app that uses OWIN?
我们有 ASP.NET 应用程序和 Global.asax.cs 文件,我们在其中使用应用程序事件处理程序如下:
protected void Application_Start(object sender, EventArgs e)
{
log.Info("The App started.");
}
protected void Application_End(object sender, EventArgs e)
{
log.Info("The App finished.");
}
我们现在想使用OWIN,这意味着添加Startup.cs文件。有什么方法可以将处理程序从 Global.asax.cs 移动到 Startup.cs 文件或其他我们可以放置日志的地方?
OwinContext in Startup.Configuration() 不同于传统的 ASP.NET HttpContext 存在于 MvcApplication.Application_Start() 中。两者都使用不同的管道。
因此,您不能在 Startup.Configuration()
中使用 MvcApplication.Application_Start()
我们有 ASP.NET 应用程序和 Global.asax.cs 文件,我们在其中使用应用程序事件处理程序如下:
protected void Application_Start(object sender, EventArgs e)
{
log.Info("The App started.");
}
protected void Application_End(object sender, EventArgs e)
{
log.Info("The App finished.");
}
我们现在想使用OWIN,这意味着添加Startup.cs文件。有什么方法可以将处理程序从 Global.asax.cs 移动到 Startup.cs 文件或其他我们可以放置日志的地方?
OwinContext in Startup.Configuration() 不同于传统的 ASP.NET HttpContext 存在于 MvcApplication.Application_Start() 中。两者都使用不同的管道。 因此,您不能在 Startup.Configuration()
中使用 MvcApplication.Application_Start()