【发布时间】:2018-09-05 14:37:43
【问题描述】:
我有一个 Web 应用程序,该应用程序有一些与之相关联的状态可能不会丢失。所以我想我将使用Application_Start 和Application_End 事件来重新水化并将该状态从/存储到数据库。但我正在 Azure 中进行测试,并且从未调用过 Application_End。
这是我的测试代码 global.asax:
public class Application : System.Web.HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
System.Diagnostics.Trace.WriteLine("APPLICATION STARTED.");
}
void Application_End(object sender, EventArgs e)
{
System.Diagnostics.Trace.WriteLine("APPLICATION ENDED.");
}
protected void Application_Start()
{
}
}
“APPLICATION_END”永远不会显示在应用程序日志中。
【问题讨论】:
-
注意:如果状态不能丢失:那么,您需要随时保存到可靠的存储。其他一切都只是“这可能会奏效,在美好的一天”。所以只要这是“如果保留状态会更方便:很好
标签: c# .net azure asp.net-web-api