概述
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 ();
}
{
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()),"");
}
{
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 ();
}
{
//装箱
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 " ;
Response.Buffer = true ;
Response.ExpiresAbsolute = DateTime.Now.AddSeconds( - 1 );
Response.Expires = 0 ;
Response.CacheControl = " no-cache " ;
最后
以上就是搞怪蜗牛为你收集整理的计数器的全部内容,希望文章能够帮你解决计数器所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复