在线人数和访问人数统计以及获取当前动态时间
ahtjh 2012-12-21 04:42:25 我在做网站页面的时候,需要做到获取访问该网站的总人数和当前在线的人数,同时也要获得到当前系统的时间(要是动态的,而且要是英文版的)。可是我在做完这些的时候动态时间获取的小时值和系统的时间相差好几个小时,同时在获取当前网站的访问总人数和在线人数在不同的浏览器中运行后得到的数值都不一样,这个是怎么回事!求大神指教!附录代码(我是用母版页加用户控件做的):
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Time.ascx.cs" Inherits="uc_Time" %>
<div>
<%--<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>--%>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" ForeColor="Black" Style="text-align: left;
width: 382px; padding-top: 22px" Text="Label" Width="200px"></asp:Label><br />
<asp:Label ID="Label2" runat="server" ForeColor="Black" Style="text-align: left;
padding-top: 10px" Text="Label" Width="200px"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timer" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Timer ID="timer" runat="server" OnTick="timer_Tick" Interval="1000">
</asp:Timer>
</div>
public partial class uc_Time : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void timer_Tick(object sender, EventArgs e)
{
int allUser = (int)Application["AllUser"];
int onUser = (int)Application["OnUser"];
Label1.Text = "Time:" + System.DateTime.Now.ToString("r");
Label2.Text = "Total:" + allUser + " " + "Online:" + onUser + "<br/>";
// Response.Write(Application["Chat"] as string);
}
}