asp.net中显示在线用户
asp.net中显示在线用户
private static System.Threading.Timer timer;
private const int interval = 1000 * 60 * 20;//检查在线用户的间隔时间
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
public Global()
{
InitializeComponent();
}
protected void Application_Start(Object sender, EventArgs e)
{
if (timer == null)
timer = new System.Threading.Timer(new System.Threading.TimerCallback(ScheduledWorkCallback),
sender, 0, interval);
DataTable userTable = new DataTable();
userTable.Columns.Add("UserID");//用户ID
userTable.Columns.Add("UserName");//用户姓名
userTable.Columns.Add("FirstRequestTime");//第一次请求的时间
userTable.Columns.Add("LastRequestTime");//最后一次请求的时间
userTable.Columns.Add("ClientIP");//
userTable.Columns.Add("ClientName");//
userTable.Columns.Add("ClientAgent");//
userTable.PrimaryKey = new DataColumn[]{userTable.Columns[0]};
userTable.AcceptChanges();
Application.Lock();
Application["UserOnLine"] = userTable;
Application.UnLock();
}
protected void Session_Start(Object sender, EventArgs e)
{
}
protected void Application_BeginRequest(Object sender, EventArgs e)
{
}
protected void Application_EndRequest(Object sender, EventArgs e)
{
}
protected void Application_AcquireRequestState(Object sender, EventArgs e)
{
if(sender == null) return;
if(!(sender is HttpApplication)) return;
HttpApplication mApp = (HttpApplication)sender;
if(mApp.Context.Session == null) return;
if(mApp.Context.Session["UserID"]==null ) return;
string userID = mApp.Context.Session["UserID"].ToString();
if(Application["UserOnLine"] == null) return;
if(!(Application["UserOnLine"] is DataTable)) return;
DataTable userTable = (DataTable)Application["UserOnLine"];
DataRow curRow = userTable.Rows.Find(new object[]{userID});
if(curRow != null)
{
this.GetDataRowfromHttpApp(mApp,ref curRow);
}
else
{
DataRow newRow = userTable.NewRow();
this.GetDataRowfromHtt
相关文档:
引自: http://renhappy20066.blog.163.com/blog/static/112080786200961172521923/
ASP.NET页面重定向方法小结
asp.net 2009-07-11 07:25 阅读54 评论0
字号: 大大 中中 小小
页面重定向的使用很多,实现方法也有不同,自己也试过几种,现在总结一下。 ......
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient; ......
实现ASP.NET生成随机密码功能是很容易的,下面的代码给出了完整的实现方法:
public static string MakePassWord(string PwdChars, int Pwdlen)
{
string mpstr = "";
int iRandNum;
Random mrnd = new Random();
for (int ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;
using System.Net.Configuration;
namespace BCore.PubFunction
{
public class MailHandler
{
&n ......
protected void Unite(GridView gv)
{
int i;
string LastType1;
int LastCell;
if (gv.Rows.Count > ......