pass values or data from one page to another when you use Login control in ASP.NET 2.0

后端 未结 4 1553
盖世英雄少女心
盖世英雄少女心 2021-01-26 01:12

I am using Login Control available in ASP.NET 2.0 in the login page. Once the user is authenticated successfully against database, I am redirecting the user to home.aspx. Here,

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-26 02:13

    As ScottS said, if you're using the standard login controls and a membership provider this information is already available to you in User.Identity.Name.

    The only reason I'm posting an answer is to mention the LoginName control, which you can drop on a page/master page and have this done automatically for you:

    
    

    This will render out "Welcome, Zhaph" when the user is logged in, or nothing if they are not.

    You can also combine this quite nicely with the LoginView and LoginStatus controls:

    
      
        
      
      
        
    Welcome back -

    This combination of controls will do the following:

    1. If the user isn't logged in display: Register or Login
    2. If the user is logged in display: Welcome back Zhaph - Logout

    The Login links is populated by the settings in web.config, and generated by the LoginStatus control.

提交回复
热议问题