简体   繁体   English

当应用程序强制结束时,ASP.Net应用程序数据未更新

[英]ASP.Net Application Data not updating when application forcibly end

I have asp.net application. 我有asp.net应用程序。

I am forcibly ending this application and on the time of that i want to update my view page count value in database . 我强行结束此应用程序,并希望在此时间更新database视图页面计数值。

I am forcibly stopping my application that time Application_End() not firing in Global.aspx file. 我强行停止我的应用程序,使Application_End()不在Global.aspx文件中触发。 when i stop process normally then Application_End() event fired. 当我正常停止进程时,将触发Application_End() event but my requirement is that, 但我的要求是

Data should be update in both cases forcibly or gracefully stop application. 在两种情况下都应强制或正常停止应用程序更新数据。 Suggest me for better solution or what other event should i use. 建议我寻求更好的解决方案或应该使用其他事件。

void Application_End(object sender, EventArgs e)
{
// Code that runs on application shut`enter code here`down
}

If I where you i would take a look at this question: How to detect a Kill Process event 如果我在哪里,我将看一个问题: 如何检测“终止进程”事件

One of the comment says 评论之一说

My point is this... you can't depend on getting a chance to save data, particularly in case of unexpected termination of your process. 我的意思是……您不能依赖于保存数据的机会,尤其是在意外终止过程的情况下。 You can certainly try to do this as much as possible, but you have to be aware that there will always be some event that could cause your application to exit without giving you a chance to save data. 您当然可以尝试尽可能多地执行此操作,但是您必须意识到,总会有一些事件可能导致您的应用程序退出而没有给您机会保存数据。 (For instance, the system's power cord could be unplugged.) I don't mean to be picky, I just wanted to point this out for others with a similar question. (例如,可以拔下系统的电源线。)我并不是要挑剔,我只是想为其他有类似问题的人指出这一点。 -reuben -鲁本

If the kind of data you are working with really are crutial, i would recommend saving them at the moment you are able to do it. 如果您正在使用的数据类型确实至关重要,我建议您在有能力时立即保存它们。 waiting for the application to be shutted down before saving data is asking for trouble. 在保存数据之前,请先等待应用程序关闭,然后再提出问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM