0

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.

4

2 回答 2

0

嘿,请参考此代码以获取 Asp.Net

string currentUsername = System.Web.HttpContext.Current.User.Identity.Name;

这是经过测试的代码。

于 2013-05-06T09:46:06.660 回答
0

请尝试以下代码以获取当前用户名

string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
于 2013-05-06T06:40:27.487 回答