1

Is it possible to get Client Computer name in asp.net web application ?

I don't want to use ActiveX object as it is not supported in all browsers.

I am building a Application which is going to hosted in Azure so it is not giving proper Computer name using bellow code.

string pCName= System.Net.Dns.GetHostEntry(this.Page.Request.UserHostAddress).HostName

This code works only with intranet application. can any one suggest me solution or any alternative solution to get Client PC Name ?

Mahesh
  • 730
  • 7
  • 26

2 Answers2

2

You can get Computer names using codes if they are in a network(intranet) which works fine as you suggested.

At the same time when the system is accessed via internet there is no computer name rather Domain name.

I want to get the machine name of the client the request is being made from. With ASP I can get the IP address. But I don’t know how to get the name of the machine. Is there something I could do from the client side?

No, the web browser client cannot determine the name of the machine.

Clients and servers should not trust each other. In the absence of authentication evidence, clients must assume that all servers are run by evil hackers and servers must assume that all clients are run by evil hackers. Once you accept that fundamental design principle then it becomes much easier to reason about client-server interactions. Think like an evil person!

More reference on the topic (Retrieving the system name) , you can refer :

Stack Overflow posts :

  1. Get Client ip address and system name
  2. How get client (user) machine name (computer name) with jQuery or JavaScript or server-side codes.

Hope that will put more light on the issue.

Community
  • 1
  • 1
Tharif
  • 13,794
  • 9
  • 55
  • 77
  • That's true @utility. can you suggest any alternate solution ? like when user hit the page we send some parameters to console application which is already installed in client machine, if that application is not running then can can we run that application from web page ? latter that console app will get the client name and using SignalR i can get that Machine name in webpage ? – Mahesh Jul 23 '15 at 06:34
  • I have build a demo at http://computername.azurewebsites.net/install/publish.htm but i am not able to run application from browser directly. each time i have to download and run that app ! – Mahesh Jul 23 '15 at 06:37
  • you could post that as an additional question..but the link doesnt look like an online application rather some software – Tharif Jul 23 '15 at 06:40
  • That's Clickonce console application ! which i made for above purpose. – Mahesh Jul 23 '15 at 06:41
  • but thats not an apt way that you are looking for ..since without installing the details must be retrieved – Tharif Jul 23 '15 at 06:43
  • ya i know ! searching for the best and apt way ! – Mahesh Jul 23 '15 at 06:45
0

You could try

Request.ServerVariables["LOGON_USER"];

Form

System.Web
tuhin
  • 103
  • 3
  • 8
  • that is giving server logon user not client. Please checkout live demo at http://computername.azurewebsites.net/ – Mahesh Jul 23 '15 at 06:28