当前位置: 代码迷 >> ASP.NET >> 求个人空间计数器的最佳代码,多谢
  详细解决方案

求个人空间计数器的最佳代码,多谢

热度:2233   发布时间:2013-02-25 00:00:00.0
求个人空间计数器的最佳代码,谢谢

页面通过地址传值确定用户的访问量,求简单快速的代码。谢谢

------解决方案--------------------------------------------------------
<div align=center>
<table>
<tr>
<td bgcolor= "#ffffff "> <div align=center> <img border=0 src= "http://c6.amazingcounters.com/counter.php? i=1214383&c=3643462 " alt= "Welcome ,My Friends! "> </div> </td>
<td align=left> <a href= "..............................自己的网页 "> 画ooO </a> </td>
</tr>
</table> </div>
------解决方案--------------------------------------------------------
关注中。。。
------解决方案--------------------------------------------------------
页面每刷新一次,某个变量加1放入cache中,每过1~10分钟(视访问量而定),cache向数据库写一次
------解决方案--------------------------------------------------------
自己写一个~用Application可以做到
只不过样子得你自己设计~
private void count()
{
Application.lock();
Application[ "Counter "] = Convert.ToInt32(Application[ "Counter "])+1;
Label1.Text = Application[ "Counter "].ToString();
Application.unlock();
}

------解决方案--------------------------------------------------------
补充~ 不定时将Count值写入database
------解决方案--------------------------------------------------------
private void count()
{
Application.lock();
Application[ "Counter "] = Convert.ToInt32(Application[ "Counter "])+1;
Label1.Text = Application[ "Counter "].ToString();
Application.unlock();
}
------解决方案--------------------------------------------------------
想请教一下如何不定时写入数据库

//用timer控件.如每隔1小时,就触发写入数据库事件...
------解决方案--------------------------------------------------------
Global中

protected void Application_Start(Object sender, EventArgs e)
{
Application[ "Counter "] = "0 ";
}
protected void Session_Start(Object sender, EventArgs e)
{
Application.lock();
Application[ "Counter "] = Convert.ToInt32(Application[ "Counter "])+1;
Application.unlock();
}
protected void Session_End(Object sender, EventArgs e)
{
Application.lock();
Application[ "Counter "] = Convert.ToInt32(Application[ "Counter "])-1;
Application.unlock();
}
  相关解决方案