On Localhost my username is ‘MTA’ when calling this code:
string opl = HttpContext.Current.User.Identity.Name.ToString();
TextBox1.Text = opl.Substring(opl.IndexOf(@"\") + 1);
OR this code:
string opl = System.Environment.UserName.ToString();
TextBox1.Text = opl.Substring(opl.IndexOf(@"\") + 1);
But after publishing and accessing the website from a Windows Server. My username is now ‘SRVCMAN’.
I believe you are looking for implementing Windows Authentication Mode.
Refer to the following articles and read about it: