Toggle navigation
首页
热门资讯
资源下载
技术博客
会员
中心
会员中心
发布博文
发布资源
首页
文章中心
C#&ASP.NET
计数器
77 阅读
0 评论
51 点赞
我是
靠谱客
的博主
搞怪蜗牛
,最近开发中收集的这篇文章主要介绍
计数器
,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
protected
void
Application_Start(Object sender, EventArgs e)
...
{
uint
count
=
0
;
StreamReader srd;
string
file_path
=
Server.MapPath (
"
Counter/counter.txt
"
);
srd
=
File.OpenText (file_path);
while
(srd.Peek ()
!=-
1
)
...
{
string
str
=
srd.ReadLine ();
count
=
UInt32.Parse (str);
}
object
obj
=
count;
Application[
"
counter
"
]
=
obj;
srd.Close ();
}
protected
void
Session_Start(Object sender, EventArgs e)
...
{
Application.Lock ();
//
数值累加,注意这里使用了装箱(boxing)
uint
jishu
=
0
;
jishu
=
(
uint
)Application[
"
counter
"
];
jishu
=
jishu
+
1
;
object
obj
=
jishu;
Application[
"
counter
"
]
=
obj;
//
将数据记录写入文件
string
file_path
=
Server.MapPath (
"
Counter/counter.txt
"
);
StreamWriter fs
=
new
StreamWriter(file_path,
false
);
fs.WriteLine (jishu);
fs.Close ();
Application.UnLock ();
ZzbDbproClass m_Dbpro
=
new
ZzbDbproClass();
string
m_IPAddress
=
m_Dbpro.G_User_IP();
m_Dbpro.Add_OT_SiteLog( System.DateTime.Now, m_IPAddress, System.DateTime.Now.Month, System.DateTime.Now.Year);
m_Dbpro.Upt_OT_SiteCount(
int
.Parse(Application[
"
counter
"
].ToString()),
""
);
}
protected
void
Application_End(Object sender, EventArgs e)
...
{
//
装箱
uint
js
=
0
;
js
=
(
uint
)Application[
"
counter
"
];
//
object obj=js;
//
Application["counter"]=js;
//
将数据记录写入文件
string
file_path
=
Server.MapPath (
"
Counter/counter.txt
"
);
StreamWriter fs
=
new
StreamWriter(file_path,
false
);
fs.WriteLine(js);
fs.Close ();
}
//
禁cache
Response.Buffer
=
true
;
Response.ExpiresAbsolute
=
DateTime.Now.AddSeconds(
-
1
);
Response.Expires
=
0
;
Response.CacheControl
=
"
no-cache
"
;
最后
以上就是
搞怪蜗牛
为你收集整理的
计数器
的全部内容,希望文章能够帮你解决
计数器
所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将
靠谱客网站
推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(
51
)
本文分类:
C#&ASP.NET
浏览次数:
77
次浏览
发布日期:2023-09-16 12:30:22
本文链接:
https://www.kaopuke.com/article/k-p-k_14_uzo_2_fw_12__7_c1.html
相关文章
.net core独立发布文件过多的问题
vue mysql webapp,使用express和vue搭建一个web应用
05统计网站的访问人数
统计网站访问人数
计数器
ASP.NET Core微服务(五)——【vue脚手架解析接口】ASP.NET Core微服务(五)——【vue脚手架解析接口】:
仿百度统计html模板,H5端集成百度统计,多页面会分来统计吗?
网站流量统计源码
评论列表
共有
0
条评论
发表评论
取消回复
登录
注册新账号
立即
投稿
返回
顶部
发表评论 取消回复