简体   繁体   English

使用会话c#成功注销

[英]Successful Logoff using Session c#

I'm trying to implement a log off system on my project. 我正在尝试在我的项目上实现注销系统。 I've the following: 我有以下内容:

mypage.cs mypage.cs

 protected void imgBtnLogOff_click( object sender, ImageClickEventArgs e )
        {
            Session.Clear();
            Session.RemoveAll();
            Session.Abandon();
            Response.Redirect( "./Logout.aspx" );
        }

Logout.aspx 注销.aspx

<h2>Thanks and come again!</h2>
        <asp:LinkButton runat="server" ID="lbLogIn" Text=" click to log in!" OnClick="login_in"></asp:LinkButton>
    </div>

Logout.aspx.cs 注销.aspx.cs

protected void login_in( object sender, EventArgs e )
        {

             Response.Redirect( "mypage.aspx" );
        }

Thing is, since it has no session,every time I enter the page in the first time this prompts for user and pw input. 问题是,由于没有会话,所以每次我第一次进入页面时都会提示输入用户和密码。 But using this logout method it redirects successfully but with the old user, without asking for information. 但是使用这种注销方法,它可以成功重定向,但可以使用旧用户进行重定向,而无需询问信息。

Any thoughts of richer ideas? 有更多想法吗?

An advice I got back then is to redirect the user to a 'logout' page in the code have - Session.RemoveAll(); 我当时得到的建议是将用户重定向到代码中的“注销”页面-Session.RemoveAll();。 and redirect to the login page. 并重定向到登录页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM