|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ASP脚本是采用明文(plaintext)方式来编写的。asp.net|asp.netglobal.asa必需放在网站根目次里
global.asa
----------------------------------------------------------------------
<scriptlanguage="c#"runat="server">
voidSession_OnStart(){
Application.Lock();
Application["whoson"]=Convert.ToInt32(Application["whoson"])+1;
Application.UnLock();
}
voidSession_OnEnd(){
Application.Lock();
Application["whoson"]=Convert.ToInt32(Application["whoson"])-1;
Application.UnLock();
}
publicvoidApplication_OnStart(){
Application.Lock();
Application["whoson"]=0;
Application.UnLock();
}
</script>
-------------------------------------------------------------------------
count_txt.asp
-------------------------------------------------------------------------
<%@Pagelanguage="C#"%>
<%@ImportNamespace="System.IO"%>
<Scriptlanguage="C#"runat="server">
publicvoidPage_Load(Objectsrc,EventArgse)
{
//以下为读取文件,以后目次必需有count.txt这个文件不然会堕落
StreamReadersr=File.OpenText(Server.MapPath(".")+"count.txt");
Application.Lock();
Application["count"]=sr.ReadLine();
Application["count"]=Convert.ToInt32(Application["count"])+1;
Application.UnLock();
sr.Close();
//创建文件
StreamWriterrw=File.CreateText(Server.MapPath(".")+"count.txt");
Application.Lock();
rw.WriteLine(Application["count"]);
Application.UnLock();
rw.Flush();//写进
rw.Close();
count_1.Text="您是本站第"+Application["count"].ToString()+"位会见者";
}
</Script>
<html>
<head>
</head>
<body>
<hr>
<asp:LabelID="count_1"runat="server"/>
</body>
</html>
</p>缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。 |
|