我做的网站计数统计为什么不起作用?
这是放在网站根目录下的Global.asa文件,同时在相同目录下还有一个counter.txt文件,里边的内容是1请大家帮我分析一下为什么我在网站首页加上<%Application("counter")%>却不起任何作用呢? 是不是代码写错了?还是有其他的方法?谢谢!
sub Application_Onstart
Application.Lock
txtpath="counter.txt"
set fso=server.CreateObject("Scripting.FileSystemObject")
set mytxt=fso.Opentextfile(txtpath,1,false)
mycount=mytxt.readLine
if mycount="" or len(mycount)=0 then
mycount=1
Application("counter")=mycount
else
Application("counter")=mycount
end if
Application.UnLock
end sub
sub Application_OnEnd
end sub
sub Session_Onstart
txtpath=server.MapPath("counter.txt")
set fso=server.CreateObject("Scripting.FileSystemObject")
set mytxt=fso.Opentextfile(txtpath,1,false)
mycount=mytxt.readLine
Application("counter")=mycount
Application.Lock
Application("counter")=Application("counter")+1
Application.UnLock
end sub
sub Session_OnEnd
txtpath=server.MapPath("counter.txt")
set fso=server.CreateObject("Scripting.FileSystemObject")
set mytxt=fso.Opentextfile(txtpath,2,false)
mytxt.writeLine(Application("counter"))
end sub