Please try below code for getting current username
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Question
In my web application, I need to display the username who is currently logged in the system. Am having a Text-box and a Button in my form. Example : If the user "Admin" is currently logged in and using the (Local)system. Once I clicked the button the name Admin has to be displayed in the Text-box.
La solution
Please try below code for getting current username
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Autres conseils
Hey Please refer this code for Asp.Net
string currentUsername = System.Web.HttpContext.Current.User.Identity.Name;
This is tested code.