if (HttpContext.Current.Cache[guid.ToString()] == null)
{
logger.Info(string.Format("用户:{0},IP:{1},机器名:{2}成功登录", txtUserName.Value,Request.UserHostAddress,Request.UserHostName));
FormsAuthentication.RedirectFromLoginPage(guid.ToString(), chk.Checked);
}
else
{
logger.Info(string.Format("用户:{0},IP:{1},机器名:{2} 验证成功,但已有人使用同用户名登录", txtUserName.Value, Request.UserHostAddress, Request.UserHostName));
this.RegisterStartupExtAlertDialog("login_having", "已有人使用相同用户名登录,请确认你的账户没有被盗用!<br/>如果是因为你上次意外退出,请稍等20秒钟后重试!");
}
<asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="Timer1_Tick" Enabled="false" />
protected void Timer1_Tick(object sender, EventArgs e)
{
HttpContext.Current.Cache.Insert(this.UserID.ToString(), DateTime.Now, null, DateTime.Now.AddSeconds(20), TimeSpan.Zero);
}