易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

ASP.NET页面重定向方法小结

引自: http://renhappy20066.blog.163.com/blog/static/112080786200961172521923/
ASP.NET页面重定向方法小结
asp.net   2009-07-11 07:25   阅读54   评论0  
字号: 大大  中中  小小
页面重定向的使用很多,实现方法也有不同,自己也试过几种,现在总结一下。 ......

ASP.NET 生命周期

ASP.NET 生命周期
对于Asp.net页面层开发无论是写页面还是写控件,我觉得都可以用一句话描述:"Do the right thing at the right time in the right place."
本文通过记录页面事件的触发顺序看请求的处理流程,从中可以看出ASP.NET 的生命周期
创建一个网站,在页面上添加一个Label和一个Button,在Default.aspx.cs中修改 ......

ASP.NET编程的十大技巧


ASP.NET编程的十大技巧
发布日期:2008-08-03
1、在使用Visual Studio .NET时,除直接或非引用的对象外,不要使用缺省的名字
.NET带来的好处之一是所有的源代码和配置文件都是纯文本文件,能够使用Notepad或WordPad等任意的文本编辑器进行编辑。如果不愿 意,我们并非一定要使用Visual Studio .NET作为集成开发环境。 ......

浅析ASP.NET生成随机密码(转)

 实现ASP.NET生成随机密码功能是很容易的,下面的代码给出了完整的实现方法:
public static string MakePassWord(string PwdChars, int Pwdlen)
{
    string mpstr = "";
    int iRandNum;
    Random mrnd = new Random();
    for (int ......

Asp.Net Master模板页的控件和属性

 内容页访问MasterPage中的控件,有两种解决方案:
一、是用弱类型访问
    使用 FindControl 方法获取模板页的控件
    ((Label)Master.FindControl("Label1")).Text = "xxx";
  
二、给模板页添加属性来使用强类型访问(推荐)
    模板页定义;
&nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号