注销功能错误

时间:2017-02-22 14:12:36

标签: javascript

我有一个ASP.NET Web应用程序,其中我有一个Logout功能。下面是我在JavaScript中注销的代码。 但我不希望Logout关闭浏览器。我想实现用户单击Logout和的功能 它应该清除cookie / session并强制应用程序登录。Like this Login pop up它还应该在所有登录时运行注销功能 浏览器(Chrome,IE,FF)。我目前的代码对Chrome不起作用。 有人会帮我解决这个问题吗?

function Logout() {
if (confirm('Are you sure you want to close the browser?')) {
    open(location, '_self').close();
} else {
    // Do nothing!
}

}

1 个答案:

答案 0 :(得分:0)

我认为JavaScript无法清除会话。服务器端应该照顾好。

protected void LogoutBtn_Click(object sender, EventArgs e)
    {
        FormsAuthentication.SignOut();
        Roles.DeleteCookie();
        Session.Clear();
        Response.Redirect("login.aspx");
    }