半点优化网 http://www.bdxc.net/
当前位置首页 > 网站技术问题> 正文

怎样在asp.net网站上写访问量的代码统计

2022-04-23 09:21:40 暂无评论 265 网站技术问题 站上   访问量   统计

看到你写的代码,我想告诉你,访问量应该存在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,pathcount= 1path = server.Mappath(count.txt)Set fs=CreateObject(scripting.filesystemobject)if(fs.FileExists(path))thenSet hs=fs.opentextfile(path)count=hs.ReadLineif session(iscount)= thensession(iscount)=iscountcount=count+1end ifhs.closeSet hs=fs.opentextfile(path,2,true)hs.writeline(count)elseSet hs=fs.createtextfile(path)hs.writeline(1)end ifresponse.write 您是第&count&位访问者!hs.closeset fs=nothing%>

猜你喜欢