asp.net统计在线人数,登陆时间,退出时间如何实现?请高手指点!谢谢!
考虑非正常退出!
考虑非正常退出!
解决方案 »
- asp.net怎么让服务端模拟其他用户执行exe程序,而不是默认的ASPNET
- sql 2000中怎么到处一个表的sql脚本。并且含这个表里的数据
- 分数实在太少,没有办法,十分抱歉,问个access连接的语法问题。
- 如何将 txt 导入 datatable
- 关于文本框输入问题
- 有关查询数据库和后台上传的问题
- 各位大俠,幫忙看下是什麼問題?????
- 如何设置DataGrid控件中的日期显示的格式: 2004-1-1 12:00:00 -> 2004-1-1
- 外观显示问题,如何在runTime时控制DATAGRID中一个模板列里面的HyperLink,要求使HyperLink.Text根据指定的宽度自动换行。谢谢!
- 四处求救!至今没有解决的问题!
- 怎么弹出一个提示窗口?进来有分。。
- 如何控制扫描仪
在最开始定义APPLIACTION["ONLINE"]=0在sessionSTAR事件写:application["online"].lock()
再获取值+1然后application["online"].Unlock()
在结束时重复上面的动作!在程序中访问这个就不用我写了!
希望能帮助到你!
统计时间也是这样统计的哦!
<%@ Page Language= "c# " debug= "true " %>
<html>
<head>
<SCRIPT LANGUAGE= "c# " RUNAT= "server ">
private void Page_Load(object sender, System.EventArgs e)
{
Visitors.Text = "本站当前有: <b> " + Application[ "user_sessions "].ToString() + " " + "</b> 位访问者 ! ";
}
<title>在线用户</title>
</head>
<body>
<asp:label " runat= "server " /><br>
</body>
</html> global.asax文件下
<script language= "c# " runat= "Server ">
protected void Application_Start(Object sender, EventArgs e)
{
Application[ "user_sessions "] = 0;
}
protected void Session_Start(Object sender, EventArgs e)
{
Application.Lock();
Application[ "user_sessions "] = (int)Application[ "user_sessions "] + 1;
Application.Unlock();
}
protected void Session_End(Object sender, EventArgs e)
{
Application.Lock();
Application[ "user_sessions "] = (int)Application[ "user_sessions "] - 1;
Application.Unlock();
}
</script>
目前在线人数:Membership.GetNumberOfUsersOnline();
当前用户在线时长:Membership.UserIsOnlineTimeWindow;
取得当前登录用户的相关信息:使用MembershipUser类 protected void Page_Load(object sender, EventArgs e)
{
//若用户通过验证,则显示相关信息
if (User.Identity.IsAuthenticated)
{
MembershipUser myUser = Membership.GetUser();
if (myUser.UserName != null)
{
Response.Write("用户帐号:" + myUser.UserName + "<BR>");
Response.Write("电子邮件信箱:" + myUser.Email + "<BR>");
Response.Write("密码提示问题:" + myUser.PasswordQuestion + "<BR>");
Response.Write("是否允许验证:" + (myUser.IsApproved == true ? "允许" : "不允许") + "<BR>");
Response.Write("用户是否在线:" + (myUser.IsOnline == true ? "在线" : "离线") + "<BR>");
Response.Write("帐号创建时间:" + myUser.CreationDate + "<BR>");
Response.Write("上一次登录日期:" + myUser.LastLoginDate + "<BR>");
Response.Write("上一次操作日期:" + myUser.LastActivityDate + "<BR>");
Response.Write("上一次退出日期:" + myUser.LastLockoutDate + "<BR>");
Response.Write("密码更改上一次日期:" + myUser.LastPasswordChangedDate + "<BR>");
Response.Write("帐号是否锁定:" + (myUser.IsLockedOut == true ? "被锁定" : "无锁定") + "<BR>");
} new AlertMessage().showMsg(this.Page, "帐号密码验证成功!");
}
else
{
new AlertMessage().showMsg(this.Page, "请进行帐号登录!");
FormsAuthentication.RedirectToLoginPage();
}
}
登录时间 那就是登陆按钮的事件里写了,每当点击登陆后把时间记录下来
退出时间 一是设计一个退出按钮,点击以后记录一下时间;二是没点击的时候页面销毁时记录一下时间