Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Need help with LoggedIn Event from Login control

$
0
0

Hey guys.  Need a little help.  I'm doing some self-study and began reading up and experimenting with the Login control.  The task is simple...I'm trying to write to a table when a user logs in.  So on the Login1_LoggedIn event, I'm calling a little method I wrote which simply writes to a database the user name and the time.

Problem is that when the user is logging in, it's write an empty string for the user name.  If I log in from another pageand then fire this event while already logged it, it works fine.    I would think that the LoggedIn event fires when they do log in and it can grab their Username. (Yes, the user is being authenticated.  UID and PWD are correct).

Thoughts?  Suggestions?  Better approach?

 protected void Login1_LoggedIn(object sender, EventArgs e)
    { RecordInLog(User.Identity.Name);  }



    private void RecordInLog(string userName)
    {

        //...write to database.... 
        try
        {
            //do stuff
        }


        catch (Exception objException)
        {
//catch error
        }


        finally
        {
            //close connection
        }

    }

Perhaps I'm not understanding the control's page life cycle. Little help is appreciated!


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>