---
title: "How to get Client Machine Name And Server Name"  
description: "How to get Client Machine Name And Server Name"  
author: "Samuel Fernandes"  
published: 2014-09-22  
updated: 2014-09-22  
canonical: https://www.mindstick.com/forum/2272/how-to-get-client-machine-name-and-server-name  
category: "c#"  
tags: [".net", "asp.net mvc", "c#"]  
reading_time: 1 minute  

---

# How to get Client Machine Name And Server Name

How to get [Client](https://www.mindstick.com/articles/23198/3-steps-to-ensure-that-your-client-portal-is-impeccable) Machine Name And [Server Name](https://answers.mindstick.com/qa/110129/how-to-change-discord-server-name)

## Replies

### Reply by Anonymous User

Hi SamuelHere Html code\
<h1>Client Machine [Name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide):<span> @ViewBag.PcName</span></h1>\
<h1>[Server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) Machine Name: <span>@ViewBag.HostPCName</span></h1><p></p>\
Here is C# Code:\
public ActionResult Index() { string PCName = Dns.GetHostEntry(Request.ServerVariables["REMOTE_ADDR"]).HostName; string HostPCName = Dns.GetHostName(); ViewBag.PcName = PCName; ViewBag.HostPCName = HostPCName;\
string strDNS = Dns.GetHostName(); string aa = System.Security.Principal.WindowsIdentity.GetCurrent().User.ToString().Trim(); string bb = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Substring(5).ToString().Trim();\
//Retrieving Server IPAddress string strHostName = System.Net.Dns.GetHostName(); string strHostIPAddress = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).GetValue(0).ToString();\
string a = System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName; //string b = ServerVariables["REMOTE_ADDR"]; string c = Request.UserHostAddress; string d = Server.HtmlEncode(Request.UserHostName);\
//Get The User Ip Address string ipAddress = "117.214.129.9"; string str = Request.Form["hdn"]; string MyUserName = Environment.UserName; string MyDomainName = Environment.UserDomainName; string MyComputerName = System.Net.Dns.GetHostName(); string MyIPAddress = System.Net.Dns.GetHostEntry(MyComputerName).AddressList[0].ToString();\
//Retrieving Client Machine details System.Net.IPAddress[] strClientIPAddress = System.Net.Dns.GetHostAddresses(Environment.MachineName); string strClientMachineName = Environment.MachineName.ToString().Trim(); string strClientUserName = Environment.UserName.ToString().Trim(); string strClientDomainName = Environment.UserDomainName.ToString().Trim(); string strClientOSVersion = Environment.OSVersion.ToString().Trim();\
string[] computer_name = System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName.Split(new Char[] { '.' }); computer_name[0].ToString();\
//string getUserHostAddress = HttpContext.Current.Request.UserHostAddress; //string getUserHostName = HttpContext.Current.Request.UserHostName; return View(); }


---

Original Source: https://www.mindstick.com/forum/2272/how-to-get-client-machine-name-and-server-name

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
