在Web应用程序使用应用程序变量的优点和缺点 [英] Advantages and disadvantages of using application variables in web applications

查看:163
本文介绍了在Web应用程序使用应用程序变量的优点和缺点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有在我的asp.net web应用程序中使用的应用程序变量。我使用ASP.NET2.0。是否有使用applicationvariables的任何缺点。

I haven't used the application variables in my asp.net web applications. I'm using asp.net2.0. Is there any disadvantages of using applicationvariables.

推荐答案

你是什么应用程序变量是什么意思?这样的:

What do you mean by application variables? Like:

private int _key = 0;

如果是这样,这些类型的变量没有保存的网页请求之间。当页面卸载,你必须使用会话或缓存或视图状态来存储它喜欢的:

If so, these kinds of variables are not saved between web requests. When the page unloads, and you have to use session or cache or viewstate to store it like:

ViewState["Key"] = 1;

Session["Key"] = 1;

从这里加载页面时重新加载它。如果你的意思是别的东西,请评论,我会更新我的回应。

And reload it from here when the page loads again. If you mean something else, please comment and I'll update my response.

编辑:对于应用程序,检查这些了:

For application, check these out:

  • http://weblogs.asp.net/plip/archive/2003/12/01/40526.aspx
  • http://www.dotnetheaven.com/UploadFile/mahesh/ApplicationState05102005051501AM/ApplicationState.aspx

应用程序状态的应用范围的存储,所以要限制一个用户,你需要将用户ID追加到键,或者使用会话。

Application state is application-wide storage, and so to limit to a user, you need to append the user ID to the key, or use session.

这篇关于在Web应用程序使用应用程序变量的优点和缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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