How to Read the Client's MAChine/Computer Name from the Browser

How can I read the client's machine/computer name from the browser?

You can do it with IE 'sometimes' as I have done this for an internal application on an intranet which is IE only. Try the following:

function GetComputerName() {
try {
var network = new ActiveXObject('WScript.Network');
// Show a pop up if it works
alert(network.computerName);
}
catch (e) { }
}

It may or may not require some specific security setting setup in IE as well to allow the browser to access the ActiveX object.

Here is a link to some more info on WScript: More Information

How to get clients computer name using asp.net mvc?

No you can't, unless the client sends such info when making HTTP requests. By "client", I'm referring to any - some app, browser, etc.

You can inspect your own browser request flow using standard browser dev tools and see exactly what info your browser is sending. It will not have your machine name (unless something in your machine is and that would likely be a problem).

That said, HTTP Header data is what you have aside from standard network info such as IP address (which also isn't guaranteed to be the client's IP address - it could be the client's network address). The closest you can get to is hostname if it exists, and even then, just like IP address, is not guaranteed to be machine name.

A possible exception would be in an internal network (LAN).

How to get client's computer name

Two things to consider:

  1. Take into account that HttpContext.Current.Request.ServerVariables.Item("REMOTE_HOST") will return the name of the host making the request, not the address.
  2. Try doing System.Net.Dns.GetHostByAddress(Request.ServerVariables.Item("REMOTE_HOST")).HostName instead.

You can find a list of the Server Variables at Microsoft's MSDN website.

Hope that helps,

Determine Client's Computer Name

I got it working using the following:

string IP = Request.UserHostName;
string compName = CompNameHelper.DetermineCompName(IP);

code from compnamehelper:

public static string DetermineCompName(string IP)
{
IPAddress myIP = IPAddress.Parse(IP);
IPHostEntry GetIPHost = Dns.GetHostEntry(myIP);
List<string> compName = GetIPHost.HostName.ToString().Split('.').ToList();
return compName.First();
}

Get client computer name in web application

Your Javawebstartet Application could Host Websocket listener. So you could access this application via Websocket from javascript. Works only with http, not https

On JavaSide use the websocket implementation of http://java-websocket.org/

In Javascript I use https://code.google.com/p/jquery-websocket/
You can find examples there too.
The websocket communication is async. Create the WS with the callback method for the response

var ws = $.websocket("ws://127.0.0.1:" + lport + "/", {
events: {
say: function (e) {
//showMsg(e.data);

}
}
});

and call the server with

ws.send(0, jsonData)

How to get client computer name in node js

NodeJS DNS Reverse Lookup will do the trick. It is the only way. Check this link for more information :)

https://nodejs.org/api/dns.html#dns_dns_reverse_ip_callback

Try this below code

require('dns').reverse(req.connection.remoteAddress, function(err, domains) {
console.log(domains);
});


Related Topics



Leave a reply



Submit