Last post Jul 11, 2019 02:17 PM by PatriceSc
Jul 09, 2019 08:35 PM|markdirtyboy|LINK
I'm trying to get the name of the client computer with this code
IPAddress iP = null;
IPAddress.TryParse(Request.ServerVariables["REMOTE_HOST"],out iP); clientMachineName = Dns.GetHostEntry(iP).HostName;
on the computer where I'm programming it worked but when it's on a server and I open the page in another computer it sends me an error:
No such host is known
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.Sockets.SocketException: No such host is known
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
how can I do that
Jul 09, 2019 09:34 PM|Mikesdotnetting|LINK
You can't get the name of the client machine. That information is not accessible to code that executes on the web server - unless the client and the web server are the same machine as if the case when you are running the application on your dev machine.
The information is not accessible to code that executes in the browser, either.
If you want to uniquely identify a user, you should implement some kind of login based authentication.
Jul 09, 2019 09:38 PM|PatriceSc|LINK
It should work if both machines are in the same network. You should be prepared for this to fail if this is not the case. The name of a machine doesn't make sense outside its own local network (unless a name is explicitly exposed as done for web servers).
Jul 10, 2019 11:32 PM|KathyW|LINK
I am curious: Why would you want to do that?
First, unless this is an intranet site, all computers on the same site network, you can't do what you want.
And if it is an internet (public) site, the information would be useless to you. If I named my computer "Hal" or "Daisy", there is no reason to assume no one else named their computer "Hal" or "Daisy". And what a visitor to your public site names their
personal computer is not really for your eyes.
Jul 11, 2019 01:19 PM|markdirtyboy|LINK
this is an Intranet the server is in one VLAN and the clients are in another, what I wanna do is get the computer name and with that get all the information that I have in one Database and work with that information
Jul 11, 2019 02:17 PM|PatriceSc|LINK
Call your network admin to discuss about that. IMO it might be even forbidden anyway in your company.
Ok but which real value do you expect from having a machine name? You don't have already a user name?