IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
Environment.UserDomainName;
properties.DomainName;
System.Web.HttpContext.Current.Request.LogonUserIdentity.Name
System.Security.Principal.WindowsIdentity.GetCurrent().Name;
我在C#的Properties上面尝试过,但是没有运气。它在本地计算机上工作正常。
我的问题:我在abc.com域中托管了一个Web应用程序,并且当我在域外部或从其他外部域计算机(从客户端系统)访问此站点时,URL为abc.com如何使用c#获取其(客户端)系统域名,Jquery或Javascript。
使用C#,jQuery,JS的任何解决方案?预先感谢。
基于关于JS解决方案的以下答案:JavaScript - How to get the name of the current user
我可以添加以下内容:
尝试这样,这样您将获得主机名
string ipAddress = Request.UserHostAddress;
IPHostEntry entry = Dns.GetHostEntry(ipAddress);
string domainName = entry.HostName;
and for computer name you can do like this
var comutername= HttpContext.Current.Server.MachineName
并且在您的JavaScript中,您将通过使用ActiveXObject作为获得计算机名称
function GetClientInfo() {
var net = new ActiveXObject("wscript.network");
alert("Computer Name : " + net.ComputerName + "\n User Name : " + net.UserName + "\n Domain Name :"
+ net.UserDomain);
}