现在系统的注销是这样的,将Session清空,并指向登录页面:
Session.RemoveAll();
string script = "location.reload('Login.aspx')";
这样的注销在IE里没问题,用户在登陆的时候照样走Login.aspx里的if(!IsPostBack).一拿世界之窗问题就来了:
                   比如说拿A帐号登录一次,再拿B帐号登录一次;这两次都还走Login.aspx里的if(!IsPostBack),第三次要是再拿A帐号的话首页加载的时候就不走if(!IsPostBack)了.(本人知道世界之窗有时候注销时Session注销不了,但别人就是要用这浏览器.)
<哪位高人知道怎样写注销才能解决这个问题,并且适应于任何浏览器!请把代码贴出来下.谢谢解答了!>

解决方案 »

  1.   

    location.reload('Login.aspx')
    改为
    response.redirect("Login.aspx")
      

  2.   

    string script = "location.reload('Login.aspx')"; 改为: string script = "window.open('Login.aspx','_top')"; 或者直接使用超链接,比如再用一个页面:<a href='注销页面' target='_top'>注销</a>在注销页面里写代码:Session.RemoveAll(); Response.Redirect("login.aspx");
      

  3.   

    把SESSION的时间属性设置一下Session.timeout   后面清空!
      

  4.   


    通过票证的方法,具体代码如下:
    public void Login(string username,string password,string backUrl)
    {
    //判断该用户是否已经登录,如果登录了就不能再次登录(暂时没有完成!)
    if(UserBLL.IsLogined(username))
    {
    this.ShowMessage("该帐号已经登录!",Util.Config.ApplicationPath + "/Login.aspx");
    }
    else
    {
    bool isLogin = UserBLL.Login(username,password);
    if(isLogin==true)
    {
    SetLoginCache(username); //获取该用户的角色列表(逗号分割)
    string roleauth = RoleBLL.GetUserRole(username); //生成票证
    FormsAuthenticationTicket authTicket = new  FormsAuthenticationTicket(
    1, // version
    username, // user name
    DateTime.Now, // creation
    DateTime.Now.AddMinutes(20),// Expiration
    false, // Persistent
    roleauth,"/"); // User data
    //加密 存入Cookie
    string encryptedTicket = FormsAuthentication.Encrypt(authTicket); 
    HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName,encryptedTicket);
    Response.Cookies.Add(authCookie);  if(backUrl == string.Empty)
    {
    Response.Redirect( FormsAuthentication.GetRedirectUrl(username,false));
    }
    else
    {
    Response.Redirect(backUrl);
    }
    }
    else
    {
    if(backUrl == string.Empty)
    {
    Response.Write("<script>alert('密码错误或者用户名不存在!');location.href = '"+Request.RawUrl+"';</script>");
    }
    else
    {
    Response.Write("<script>alert('密码错误或者用户名不存在!');location.href = '"+backUrl+"';</script>");
    }
    }
    }
    } /// <summary>
    /// 设置用户登录信息
    /// 1、如果该帐号已经在别处登录,则覆盖原来已登录用户的信息(设置Hashtable的值为该帐号的对应的键值为XXXXXX)
    /// 2、如果该帐号没有被登录,则设置以当前Session ID作为键的值为该帐号
    /// </summary>
    /// <param name="userName"></param>
    private void SetLoginCache(string userName)
    {
    Hashtable hOnline = (Hashtable)Application["Online"];
    if(hOnline != null)
    {
    IDictionaryEnumerator idE = hOnline.GetEnumerator();
    string strKey = "";
    while(idE.MoveNext())
    {
    if(idE.Value != null && idE.Value.ToString()==userName)
    {
    //该帐号已经被登录           
    strKey = idE.Key.ToString();
    //将第一个人登陆的SessionID对应的用户名强制变更为XXXXXX
    hOnline[strKey] = "XXXXXX";
    break;
    }
    }
    }
    else
    {
    hOnline = new Hashtable();
    }

    hOnline[Session.SessionID] = userName;
    Application.Lock();
    Application["Online"] = hOnline;
    Application.UnLock();
    }
      

  5.   

    把Session.RemoveAll();改为:Session.Abandon();
      

  6.   


    string script = "location.reload('Login.aspx')"; 
    改为
    response.redirect("Login.aspx")
      

  7.   

    using System.Web.Security;加上下面的,基本上是没有问题了 
    FormsAuthentication.SignOut();
                Session.Abandon();
                Session.RemoveAll();
      

  8.   

    我一般用FormsAuthentication.SignOut();
                Session.Abandon();
                Session.RemoveAll();
    一般在IE和ff上测试,世界之窗没用过,也没考虑过。