More
Image
ASP.NET Security: Retrieving the Users Identity
By JC.Adinarayana Reddy On 20 Dec 2016
Categories: Asp.net
Once the user is logged in, you can retrieve the identity through the built-in User property, as shown here:
 
protected void Page_Load(Object sender, EventArgs e)
{
lblMessage.Text = "You have reached the secured page, ";
lblMessage.Text += User.Identity.Name + ".";
}
 
You don’t need to place the code in the login page. Instead, you can use the User object to examine the current user’s identity anytime you need to.
 
You can access the User object in your code because it’s a property of the current Page object. The User object provides information about the currently logged-in user. It’s fairly simple—in fact, User provides only one property and one method:
 
• The Identity property lets you retrieve the name of the logged-in user and the type of authentication that was used.
 
• The IsInRole() method lets you determine whether a user is a member of a given role (and thus should be given certain privileges).

Comments
Message :
Comments
JC.Adinarayana Reddy
.net
.net