看到你写的代码,我想告诉你,访问量应该存在application中, 而不是在session,因为访问量是对整站而言的。 当然你也可以使用cookie实现, 不过不推荐使用。 public int count; protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { try { this.count = Convert.ToInt32(Application["count"]); Application["count"]=this.count +1;//将访问次数加1 } catch (Exception ee) { } } } 以上代码简单的展示了实现思路, 希望可以帮你解决!
asp.net网站统计访问量:
参考代码如下:
<%
dim count,path
count= 1
path = server.Mappath("count.txt")
Set fs=CreateObject("scripting.filesystemobject")
if(fs.FileExists(path))then
Set hs=fs.opentextfile(path)
count=hs.ReadLine
if session("iscount")="" then
session("iscount")="iscount"
count=count+1
end if
hs.close
Set hs=fs.opentextfile(path,2,true)
hs.writeline(count)
else
Set hs=fs.createtextfile(path)
hs.writeline(1)
end if
response.write "您是第"&count&"位访问者!"
hs.close
set fs=nothing
%>