PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 22, 2022

[FIXED] How to get full host name in C#?

 August 22, 2022     .net, c#, dns, environment-variables, mdns     No comments   

Issue

I have tried by following by it just give me single name. I want full name. Ex. my system full name is "sys101.home.homeconsultancy.lan". Following code gives me just "sys101". I want full address "sys101.home.homeconsultancy.lan".

Here is my code:

string hostName = System.Net.Dns.GetHostName();

How can I get full system name?


Solution

You can use System.Net.Dns.GetHostEntry:

var fullName = System.Net.Dns.GetHostEntry(string.Empty).HostName;

If an empty string is passed as the hostNameOrAddress argument, then this method returns the IPv4 and IPv6 addresses of the local host.



Answered By - Hamid Pourjam
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing