我有IP地址,但出于某种原因,我无法正确解析名称以显示本地计算机名称。我尝试了几个方法,但它们都显示服务器主机名?
ipadd = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
IPAddress myIP = IPAddress.Parse(ipadd);
IPHostEntry GetIPHost = Dns.GetHostEntry(myIP);
//userhostname = System.Environment.MachineName;
//userhostname = Dns.GetHostName(); //Resolve ServerHostName not computer
//userhostname = HttpContext.Current.Request.UserHostName;
//userhostname = HttpContext.Current.Request.UserAgent;
userhostname = GetIPHost.HostName;
我正在尝试使用用户名
nametext = WindowsIdentity.GetCurrent().Name;
//Shows server name when deployed on server
//when debuging and running localy shows correctly current user logged in
//nametext = HttpContext.Current.Request.ServerVariables["LOGON_USER"];
// not returning anything
我更改了认证方式,但没有任何结果。
<authentication mode="Forms">
<authentication mode="Windows">