Maroof Raini

Maroof Raini

  • 1.3k
  • 453
  • 237k

Current user email ID in ASP.Net

Nov 4 2013 7:04 AM
Hi, I have created a one page application where I need to display user's email in a text box. Here user email refers to the outlook email ID of the user who is logged in into the machine. I am trying the below code 

txtEmail.Text = System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress;

The code returns correct email ID while running directly (Press F5) as [email protected]. Then I deploy my application in IIS but now on browsing the url it gives some other ID as websol@...... Can someone help me please ? I have already Checked "Basic Authentication" and "Integrated Windows Security" and unchecked "Anonymous Access" in IIS Directory Security.

Answers (4)