用户登录时如何显示LOGOUT链接 [英] hOW TO SHOW LOGOUT link when user is login

查看:67
本文介绍了用户登录时如何显示LOGOUT链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个登录表单,其中注销按钮是可见的,但我想在当前用户登录时显示注销按钮



在网站母版页中我正在使用此



i have a login form where logout button is visble but i want to show logout button when current user is log in

in site master page i am using this

protected void Page_Load(object sender, EventArgs e)
       {
 

           //LogoutLink.Visible = Page.User.Identity.IsAuthenticated;
           if (Session["Login2"] != null)
           {
               WELCOME.Text = Session["Login2"].ToString();
           }

 

 
this is logout button coding

protected void LinkButton1_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            Session.Clear();
            Response.Redirect("Login.aspx");
 
        }





任何人告诉我plesae



any one tell me plesae

推荐答案

所有你需要做的就是在没有登录时隐藏退出链接!



类似于:

All you have to do is hide the logout link when not logged in!

Something like:
if (Session["Login2"] != null)
           {
               WELCOME.Text = Session["Login2"].ToString();
               LinkButton1.Visible = true;
           }
           else
               LinkButton1.Visible = false;


hi,

你应该在你的母版页中使用登录状态控制



登录控件列表:



ChangePassword:此控件用于为用户提供更改现有密码的功能。在更改密码的过程中,用户必须提供他的旧密码然后再提供新密码。我们可以使用此控件的功能通过电子邮件发送用户密码更改确认。



CreateUserWizard:此控件用于创建新用户。我们可以添加其他步骤以从用户收集更多信息。我们还可以为此控件添加功能,以发送包含其用户名和密码的用户电子邮件。



登录:此控件用于提供用户登录网站的功能。该控件包含两个用于用户名和密码的文本框;一个用于记住密码和一个按钮的复选框控件



LoginName:此控件用于在网页上显示当前登录/验证的用户名。当没有人对网站进行身份验证时,我们可以向此控件添加功能以显示访客。



LoginStatus:此控件用于显示用户所在的信息目前已经过身份验证。如果用户经过身份验证,则会显示Logout之类的链接,如果没有,则显示Login。





LoginView:此控件用于显示用户的身份验证状态和角色。



PasswordRecovery:此控件提供恢复忘记密码的功能。我们还可以添加功能,在用户请求密码时向用户发送包含密码的电子邮件。

you should use login status control in your master page

List of controls for login:

ChangePassword: This control is used to provide the user a function to change the existing password. In the process of changing password user have to provide his old password and then new password. We can use functionality to this control to send the user password change confirmation by email.

CreateUserWizard: This control is used to create new user. We can add additional steps to collect more information from user. We also can add functionality to this control to send the user email containing his username and password.

Login: This control is used to provide the user functionality to login in website. This control contains two textboxes for username and password; one checkbox control for to remember password and one button

LoginName: This control is used to display the current logged-in/authenticated user name on web page. We can add the functionality to this control to display "Guest" when no one is authenticated to website.

LoginStatus: This control is used to display the information that user is currently authenticated or not. If user is authenticated then it will display a link like "Logout" and if not then "Login".


LoginView: This control is used to display the user''s authentication status and roles.

PasswordRecovery: This control provides the functionality to recover the forgotten password. We can also add function to send the email containing password to user when user request for password.


这篇关于用户登录时如何显示LOGOUT链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆