STATIC变量在ASP.NET应用程序中的生命周期? [英] STATIC variable's LifeTime in ASP.NET application?

查看:92
本文介绍了STATIC变量在ASP.NET应用程序中的生命周期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi开发人员,

在我的ASP.NET应用程序中,基于零售管理,我已经将 GRID VIEW 与可编辑的控件(文本框,下拉列表)用于计费.


问题是,如果我的网页在半小时内仍然保持理想状态,则会导致我的 STATIC变量丢失数据.因为我将 DATATABLE保持为STATIC变量,并更新了我的静态数据表中用户输入的gridview数据.半小时或更长时间后,它将引发错误,如找不到列名称"xxx"".因此,我最终确定了我的STATIC变量失去了它的内容.

并且,我确定它不是SESSION问题,因为使用Sessions时我的代码非常清楚(已设置有效超时)(已成功验证).


现在如何延长STATIC变量的寿命? (或)还有其他方法可以解决这种情况吗?
请帮帮我.

hi developers,

In my ASP.NET application, based on RETAIL MANAGEMENT i have used GRID VIEW with editable controls(textbox, dropdown) for Billing purpose.


The Problem is, if my webpage remains ideal for half-an-hour it cause my STATIC variables to loose data''s. Because i maintain a DATATABLE as STATIC Variable and update user entered gridview data''s in my Static datatable. After half-an-hour or more it throws error as "Cannot find Column name ''xxx''". Hence i finalize that my STATIC variable loose its contents.

And, I am sure its not SESSION problem, because my code is very clear in using Sessions(have set valid timeout)(Verified Successfully).


Now how can i extend these STATIC variable''s lifetime ? (or) Is there any other ways to handle this situation ?
Please help me out.

推荐答案

统计在应用程序运行期间一直处于活动状态-持续时间不长.实际上,从技术上讲,只有当网页完全加载到浏览器后,应用程序才能死亡.当网页刷新或重新加载,或者另一个客户端请求该页面时,将加载该应用程序的新副本.静态变量不会在此范围内维护.

将要保留的信息放在会话或Cookie中,这样您就可以在需要时将其读回.
Statics are "live" for the duration of the application - which isn''t as long as you might think. In fact, technically, it is when the web page has been completely loaded to the browser that the application can die. A new copy of the application is loaded when the web page refreshes, or reloads, or another client requests the page. Static variables are not maintained across this.

Put information you want to preserve either in the Session or in Cookies - that way you can read it back when you need it.


这篇关于STATIC变量在ASP.NET应用程序中的生命周期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆