首页 > 学院 > 开发设计 > 正文

初识 Asp.Net内置对象之Application对象

2019-11-17 01:28:48
字体:
来源:转载
供稿:网友

初识 asp.net内置对象之application对象

Application对象

Applocation对象用于共享应用程序级信息,即多个用户可以共享一个Applocation对象。

用户在请求Asp.Net文件时,将启动应用程序并且创建Application对象。一旦Application对象被创建,就可以共享和管理整个应用程序的信息。在应用程序关闭之前,Application对象一直存在,所以Application对象是用于启动和管理ASP.NET应用程序的主要对象。

Application对象常用集合

集合名
Contents用于访问应用程序状态集合中的对象名
StaticObjects确定某对象指定属性的值或遍历集合,并且检索所有静态对象的属性

Application对象常用属性

属性
AllKeys返回全部Application对象变量名到一个字符串数组中
Count获取Application对象的数量
Item允许使用索引或Application变量名称传回内容值

Application对象常用方法

方法
Add新增一个Application对象变量
Clear清除全部Application对象变量
Lock锁定全部Application对象变量
Remove使用变量名移除一个Application对象变量
RemoveAll移除全部Application对象变量
Set使用变量名称更新一个Application对象变量的内容
UnLock解除锁定的Application对象变量

1.用Application实验一个访问计数器

主要用来记录应用程序曾经被访问的次数的组件。主要通过Application对象和session对象来实现,我们在昨天的项目添加一个Global.asax文件,具体代码如下:

ip+xv3h3Hvueb4Pc2fmzsz7hTds8j6ce+/MUDPnNZ9zbqarqxdBEARBEARBEARBECQ9yTT8DBAEQRAEQRAEQRAEQdjAViAIgiAIgiAIgiAIkq7AViBIcydz9u+RZkzDXzkIgiAIgiAIkubAViBIc6fhvW4kXhr+ykEQBEEQBEGQNAe2AkGaOw3vdSPx0vBXDoIgCIIgCIKkObAVCNLcaXivG4mXhr9yEARBEARBECTNga1AkOZOw3vdSLw0/JWDIAiCIAiCIGkObAWCNHca3utG4qXhrxwEQRAEQRAESXNqZCvOLju3Xuvq7Tr+1rqzPn88ViPV7IukKHgx1Dahu8c/s7f/ZdK0wY/nfr1t/1VSrSEBafgrB0EQBEGaLaeX7l+b8X9muXVxVLHL6MVbSzOmNmeW7i9fzJuPq95m9NIydzL0Z2GbWxdHe7tmrt1XsnxptI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ZWHxe2azyEpS/DvqHoLbCVwz0oOaz0j84t702uUuArUAQpLb5ylem2Y7nV74yTZabZ9kktiLULJt+F/Fk0Z9zgUxV4HX/Js54P+uWy7biZFEUCoenil4XkW9Q6urz+3JH8WY30M4QwU+y4H6FrtzxZNG3LYMTRbZXzAkC1ZloHgfuErgHk9oZ8THRzn8h9L21DUa5LrkF/kLUUT2k/suGPZmQZ8hfdZhXIHdRh6dK3kUpHqjAB014ihGkXWJ4NyGdk/C2Ipfrp5aBzZEjY7lcf5hOcvUtsKri9FdPn/7qadLPr95WdHWxtqL77Nmz7777Lumavvvuu15HN5kOody5Dy0sRFVBbQXJ00//dkhbYe6KB9ZWsFJD2N1cnBLyiVAS9UE+deqUdFahbAUrF4hfYBfSR0DYnTZCqypIhUUT24qcJyzYm4AQW6GetILE1R

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表