Application_Start() 和 Application_End() 方法不会在 startup.cs class 和 asp.net MVC 5 中触发
Application_Start() & Application_End() methods are not fired in startup.cs class in asp.net MVC 5
在 ASP.NET MVC 5 应用程序中没有 Global.aspx.cs class 我可以使用方法 Application_Start()
和 Application_End()
。
有什么方法可以在 MVC 5 应用程序中调用这些方法吗?
您可以手动将 Global.asax
添加到您的项目中,如前所述 here。
否则,您可以在 Startup.cs
中使用 Configuration(IAppBuilder app)
或构造函数。 Configuration
被称为 "slightly later" 而不是 Application_Start
详细提到 here.
在 ASP.NET MVC 5 应用程序中没有 Global.aspx.cs class 我可以使用方法 Application_Start()
和 Application_End()
。
有什么方法可以在 MVC 5 应用程序中调用这些方法吗?
您可以手动将 Global.asax
添加到您的项目中,如前所述 here。
否则,您可以在 Startup.cs
中使用 Configuration(IAppBuilder app)
或构造函数。 Configuration
被称为 "slightly later" 而不是 Application_Start
详细提到 here.