验证模式为Form问题如题
解决方案 »
- 下拉框选中某一项后,怎么弹出新窗体?
- 跪求:在页面中实现 "浏览文件夹"
- 求助 如何获得EditItemTemplate中Dropdownlist的值
- 帮帮忙,急死我了:This function is not included in this version of jmail.
- 如何配制IIS6.0?客户端访问我的机子会弹出窗体让输入用户名和密码。Web.config中使用的是Form验证。
- Dropdownlist 三级联动 无刷新的问题
- ???操作必须使用一个可更新的查询!
- 易趣的链接,如下做的二级域名有什么用,为什么这样,这些页不在一个服务器下吗?关于网站架构的问题?
- 为什么在New OleDbConnection连接不能用application全局变量?
- .net mvc 三层是如何互相联结的?
- 用urlrewriter 在本地测试成功,在服务器上出错
- 菜鸟急救:关于vs2005绑定
then try to check wether the user is online before another one try to login.
或者用application 变量 登陆后 用登陆名保存一个值, 在登陆的时候检测一下.
if you choose database,you will hardly to control the user's leaving.
做这个需求时,确实要求要做到能监控到用户的退出,所以根据大家提供的办法,决定先采用“NqIceCoffee(进步于细节中) ”试试,看是否能达到预期的效果
protected void Session_End(Object sender, EventArgs e)
{
//当Session失效时,删除对应的登录用户数据
try
{
PublicFunction.DelLoginUser("",Session.SessionID,(Page)sender);
}
catch(Exception ex)
{
PublicFunction.MessageBox((Page)sender,ex.Message);
}
}问题:为何执行DelLoginUser时,系统会出现异常?
DelLoginUser函数代码为:
public static void DelLoginUser(string strUserName,string strSessionID,Page objPage)
{
string strSql = "";
if(strSessionID == "")
{
strSql = "Delete from tbl_UserOnline where UserName='"+strUserName+"'";
}
else
{
strSql = "Delete from tbl_UserOnline where SessionID='"+strSessionID+"'";
} SqlCommand objComm = new SqlCommand(strSql,DBConnection(objPage));
objComm.ExecuteNonQuery();
}
string uer = Convert.ToString(Cache[key]); //读取cache中用户相应的值
//判断cache中是否有用户的信息,如果没有相关的值,说明用户未登陆
if (uer == null || uer == String.Empty)
{
//定义cache过期时间 TimeSpan SessTimeout = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0); //第一次登陆的时候插入一个用户相关的cache值,
HttpContext.Current.Cache.Insert(key, key, null, DateTime.MaxValue, SessTimeout, System.Web.Caching.CacheItemPriority.NotRemovable, null);
Session["ADMINID"] = TextBox1.Text;
Response.Redirect("main.aspx");
}
else
{
//重复登陆
Response.Write("<script>alert('您的账号已经登陆!');window.location='login.aspx';</script>");
}
声明:转载
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' 在应用程序启动时运行的代码 Dim Table As Hashtable = New Hashtable '新哈希表
Application("UserVisite") = Table
End Sub
在页面程序 LOGON '用户登陆程序
......
Dim Table As Hashtable = Application("UserVisite")
Dim HashtableKey As String = UserID '用户ID 哈希表KEY
If Table.Contains(HashtableKey) = True Then '在哈希表内存在
Table(HashtableKey) = Session.SessionID
Else
Table.Add(HashtableKey, Session.SessionID)
End If以后每个页面判断
Dim Table As Hashtable = Application("UserVisite")
Dim HashtableKey As String = UserID '用户ID
If Table(HashtableKey).ToString().Equals(Session.SessionID) = False Then
'强制退出,清楚SESSION
Session.Abandon()
End If