c#获取客户端用户名

时间:2013-03-21 13:27:27

标签: c# asp.net login username

我试图获取我的客户端的用户名,但我仍然得到服务器信息。这是我的尝试:

Environment.UserName;
System.Security.Principal.WindowsIdentity.GetCurrent().User;
System.Security.Principal.WindowsIdentity.GetCurrent().Name;
System.Net.Dns.GetHostName();
Request.ServerVariables["REMOTE_ADDR"];
Request.UserHostAddress;

1 个答案:

答案 0 :(得分:1)

通常我使用User.Identity.Name,它返回访问应用程序的用户输入的登录名。

e.g。var loginName = User.Identity.Name;

相关问题