我有 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">