string sKey = this.TextBox1.Text;
// 得到Cache中的给定Key的值
string sUser = Convert.ToString(Cache[sKey]);
if(sUser==string.Empty){
if (this.TextBox1.Text == "1") {
TimeSpan SessTimeOut = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);
Cache.Insert(sKey, sKey, null, DateTime.MaxValue, SessTimeOut, CacheItemPriority.NotRemovable, null);
Session["User"] = sKey;
Response.Write("<script>alert('用户成功!')</script>");
}
}else{
Response.Write("<script>alert('用户以存在!')</script>");
}
这样写我发现。。
我把浏览器关闭后20分钟后才能在次进入
// 得到Cache中的给定Key的值
string sUser = Convert.ToString(Cache[sKey]);
if(sUser==string.Empty){
if (this.TextBox1.Text == "1") {
TimeSpan SessTimeOut = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);
Cache.Insert(sKey, sKey, null, DateTime.MaxValue, SessTimeOut, CacheItemPriority.NotRemovable, null);
Session["User"] = sKey;
Response.Write("<script>alert('用户成功!')</script>");
}
}else{
Response.Write("<script>alert('用户以存在!')</script>");
}
这样写我发现。。
我把浏览器关闭后20分钟后才能在次进入
参考
http://www.cnblogs.com/cancanwyq/archive/2008/08/02/1258608.html
http://www.cnblogs.com/liushouzhao/archive/2008/04/13/1150924.html
缓存是用来操作大量的查询数据的,节省时间,
登陆用的话没必要,直接session就行