In the Localhost, my username is "MTA" when this code is called:
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 a website with Windows Server. My username is now "SRVCMAN".
source
share