How to retrieve logged in user name in ASP.Net - Asp.Net Sample Source Code.



In this article you will get to know how to retrieve logged in user name in ASP.Net.


In the Previous articles i explained Add check boxes column in DataGridView for deleting records from databasewhat is query string and how to use it in asp.nethow to retrieve logged in user password using asp.nethow to enable password retrieval in, how to get security answer in and many more about ASP.Net.

If you’re using the Membership API in and need to retrieve a user’s name, you can do so by doing this:

Step 1.

Add Namespace

using System.Web.Security;

Step 2.

MembershipUser currentUser = Membership.GetUser(); 
string username = currentUser.UserName;

Hope this Helps.

Give your Valuable Comments.
comments powered by Disqus
Follow me on twitter
About Me
Harpreet Singh
I began programming with C++ when i was 17. Then at the middle of my study .NET came. Then I began to read C# and VB.NET. By the time i learnt SQL and ASP.NET, and developed some websites such as news portals that are active now. Currently i am running my own Software company.
More Articles