how to get computer name for client visit my app ?

Ahmed Salah Abed Elaziz 390 Reputation points
2023-12-13T06:20:22.28+00:00

suppose i work on asp.net MVC web application and this application hosted on IIS so i need to get computer name of user

visit web application as example client A have computer-001 he visit web application then get computer name computer-001 and display it on application .

computer B

have computer name computer-002 then register computer name computer-002 on web application using asp.net mvc

so exactly i need to get computer name that visit web application

        [HttpGet]
        public ActionResult GetAuditLog(ResignationRequester resignationRequester)
        {
string computername=get computer visit my web application who run my app
        }
Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Lan Huang-MSFT 30,206 Reputation points Microsoft External Staff
    2023-12-13T09:17:21.6333333+00:00

    Hi @Ahmed Salah Abed Elaziz,

    The client's computer name is not available in any way on the server. This is the nature of the http request-response. You only can have its IP address.

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

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Bruce (SqlWork.com) 81,971 Reputation points Volunteer Moderator
    2023-12-13T17:59:05.5733333+00:00

    as suggested you only get the client ipaddress. if the client is not behind a firewall or router that does not perform nat translation, you can do a dns lookup. in practice this will only work for an intranet, that is local computers on the same network as the IIS site.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.