Mega Code Archive

 
Categories / C# / Network
 

Gets an unescaped host name that is safe to use for DNS resolution

using System; public class MainClass{    public static void Main(){         // Create new Uri using a string address.                  Uri address = new Uri("http://[feff::100:29ff:fe11:1a1d%4]/temp/example.htm");                  // The following outputs "[feff::100:29ff:fe11:1a1d]".         Console.WriteLine(address.Host);                  // The following outputs "feff::100:29ff:fe11:1a1d%4".         Console.WriteLine(address.DnsSafeHost);    } }