问题描述
急啊,请问如何统计网站的总访问量和今日访问量?高手们请帮忙,先谢了,在线等...
解决方案
解决方案二:
网站日志统计
解决方案三:
申请个51啦统计不就完了~www.51.la或者干脆自己做~~~~~~
解决方案四:
就是个日志 很简单的 网上很多 找个参考下吧
解决方案五:
.aspx页面代码----------------------------------------------------------<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="UserCount.aspx.cs"Inherits="UserCount"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>UntitledPage</title></head><body><formid="form1"runat="server"><div><center><!--<font>你是本站第<%=Application["count"].ToString()%>访问者!</font>--><br/><font>你是本站今天第<%=Application["day_count"].ToString()%>访问者!</font></center></div></form></body></html>
解决方案六:
Global.asax页面代码----------------------------------------------------------------------<%@ApplicationLanguage="C#"%><%@ImportNamespace="System"%><%@ImportNamespace="System.Collections"%><%@ImportNamespace="System.ComponentModel"%><%@ImportNamespace="System.Web"%><%@ImportNamespace="System.Web.SessionState"%><%@ImportNamespace="System.IO"%><%@ImportNamespace="System.Data.OleDb"%><%@ImportNamespace="System.Data"%><scriptrunat="server">voidApplication_Start(objectsender,EventArgse){//CodethatrunsonapplicationstartupstringconnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];OleDbConnectionconn=null;intcount=0;intday_count=0;intyear=0;intmonth=0;intday=0;try{DataSetds=newDataSet();//创建数据库链接,并打开此连接conn=newOleDbConnection(connectionString);conn.Open();OleDbCommandcmd=newOleDbCommand();cmd.CommandText="selectcountfromSiteCount";cmd.Connection=conn;OleDbDataAdapteradapter=newOleDbDataAdapter();adapter.SelectCommand=cmd;adapter.Fill(ds);if(ds.Tables[0].Rows.Count!=0){System.Data.DataRowdr=ds.Tables[0].Rows[0];count=Convert.ToInt32(dr["count"].ToString());}ds.Clear();cmd.CommandText="selectcount,year,month,dayfromDayCount";cmd.Connection=conn;adapter.SelectCommand=cmd;adapter.Fill(ds);if(ds.Tables[0].Rows.Count!=0){System.Data.DataRowdr=ds.Tables[0].Rows[0];day_count=Convert.ToInt32(dr["count"].ToString());year=Convert.ToInt32(dr["year"].ToString());month=Convert.ToInt32(dr["month"].ToString());day=Convert.ToInt32(dr["day"].ToString());}DateTimetoday=DateTime.Now;if((today.Year!=year)||(today.Month!=month)||(today.Day!=day)){day_count=0;}Application["count"]=count;Application["day_count"]=day_count;}catch(OleDbExceptionex){throwex;}finally{try{if(conn!=null)conn.Close();}catch(OleDbExceptionex){throwex;}}}voidApplication_End(objectsender,EventArgse){//Codethatrunsonapplicationshutdownintcount=0;count=(int)Application["counter"];intday_count=(int)Application["day_count"];stringconnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];OleDbConnectionconn=null;DateTimetoday=DateTime.Now;try{DataSetds=newDataSet();//创建数据库链接,并打开此连接conn=newOleDbConnection(connectionString);conn.Open();OleDbCommandcmd=newOleDbCommand();cmd.CommandText="updateSiteCountsetcount="+count;cmd.Connection=conn;OleDbDataAdapteradapter=newOleDbDataAdapter();adapter.UpdateCommand=cmd;cmd.ExecuteNonQuery();cmd.CommandText="updateDayCountsetcount="+day_count+",year="+today.Year+",month="+today.Month+",day="+today.Day;cmd.Connection=conn;adapter.UpdateCommand=cmd;cmd.ExecuteNonQuery();}catch(OleDbExceptionex){throwex;}finally{try{if(conn!=null)conn.Close();}catch(OleDbExceptionex){throwex;}}}voidApplication_Error(objectsender,EventArgse){//Codethatrunswhenanunhandlederroroccurs}voidSession_Start(objectsender,EventArgse){//CodethatrunswhenanewsessionisstartedApplication.Lock();intcount=0;intday_count=0;DateTimetoday=DateTime.Now;if(Application["count"]!=null){objectobj=Application["count"];objectobj_day=Application["day_count"];count=(int)obj;day_count=(int)obj_day;count++;day_count++;Application["count"]=count;Application["day_count"]=day_count;stringconnectionString=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];OleDbConnectionconn=null;try{DataSetds=newDataSet();//创建数据库链接,并打开此连接conn=newOleDbConnection(connectionString);conn.Open();OleDbCommandcmd=newOleDbCommand();cmd.CommandText="updateSiteCountsetcount="+count;cmd.Connection=conn;OleDbDataAdapteradapter=newOleDbDataAdapter();adapter.UpdateCommand=cmd;cmd.ExecuteNonQuery();cmd.CommandText="updateDayCountsetcount="+day_count+",year="+today.Year+",month="+today.Month+",day="+today.Day;cmd.Connection=conn;adapter.UpdateCommand=cmd;cmd.ExecuteNonQuery();}catch(OleDbExceptionex){//alert("数据库错误:"+ex.Message);}finally{try{if(conn!=null)conn.Close();}catch(OleDbExceptionex){//alert("数据库错误:"+ex.Message);}}}else{Application_Start(sender,e);}Application.UnLock();}voidSession_End(objectsender,EventArgse){//Codethatrunswhenasessionends.//Note:TheSession_Endeventisraisedonlywhenthesessionstatemode//issettoInProcintheWeb.configfile.IfsessionmodeissettoStateServer//orSQLServer,theeventisnotraised.}</script>
解决方案七:
楼主自己该数据库~~~
解决方案八:
谢谢,sunlovesea!