How will you get a User Identity in an application?

 Posted by Tripati_tutu on 10/29/2010 | Category: ASP.NET Interview questions | Views: 2786 | Points: 40

With the help of User object’s Identity property you can be able to get User Identity. The Identity property which returns an object that includes the user name and the role information.

Sample Code Snippet:
public partial class _Default : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)
Label1.Text = User.Identity.IsAuthenticated.ToString();
Label2.Text = User.Identity.Name;
Label3.Text = User.Identity.AuthenticationType;

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response