首先在Global中写如下代码:
protected void Session_Start(Object sender, EventArgs e)
...{
ArrayList lstName=new ArrayList();
this.Application.Add("name",lstName);
}
//****************************************************************************************************8
protected void Session_End(Object sender, EventArgs e)
...{
Application.Lock();
string str=Session["name"].ToString();
ArrayList lstName=(ArrayList)this.Application["name"];
Application.UnLock();
}
protected void Session_Start(Object sender, EventArgs e)
...{
ArrayList lstName=new ArrayList();
this.Application.Add("name",lstName);
}
//****************************************************************************************************8
protected void Session_End(Object sender, EventArgs e)
...{
Application.Lock();
string str=Session["name"].ToString();
ArrayList lstName=(ArrayList)this.Application["name"];
Application.UnLock();
}
然后在登陆页面写代码
string username=this.txtName.Text.Trim();
ArrayList lstName=(ArrayList)this.Application["name"];
foreach(string strname in lstName)
...{
if(username.Equals(strname))
...{
Response.Redirect("User_Login.aspx");
}
}
lstName=(ArrayList)Application["name"];
lstName.Add(this.txtName.Text.Trim());
this.Application.Lock();
this.Application["name"]=lstName;
Session["name"]=username;
this.Application.UnLock();
this.Response.Redirect("main.aspx");
string username=this.txtName.Text.Trim();
ArrayList lstName=(ArrayList)this.Application["name"];
foreach(string strname in lstName)
...{
if(username.Equals(strname))
...{
Response.Redirect("User_Login.aspx");
}
}
lstName=(ArrayList)Application["name"];
lstName.Add(this.txtName.Text.Trim());
this.Application.Lock();
this.Application["name"]=lstName;
Session["name"]=username;
this.Application.UnLock();
this.Response.Redirect("main.aspx");
本文作者:9who 来源:http://www.cnblogs.com/9who/
CIO之家 www.ciozj.com 微信公众号:imciow