From 6e6673e3180790326aa000b64ed63484aa54eca5 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 10 Feb 2026 14:07:06 +0000
Subject: [PATCH 1/4] Initial plan
From 95a11396458e36abe07f558b867d2f49ecc8ac06 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 10 Feb 2026 14:14:49 +0000
Subject: [PATCH 2/4] Document Host, IdnHost, and DnsSafeHost differences with
examples
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
---
.../System/Uri/HostComparison/Project.csproj | 6 ++
.../System/Uri/HostComparison/source.cs | 50 +++++++++++
.../System/Uri/HostComparison/Project.csproj | 6 ++
.../System/Uri/HostComparison/source.fs | 44 ++++++++++
.../System/Uri/HostComparison/Project.csproj | 6 ++
.../System/Uri/HostComparison/source.vb | 48 ++++++++++
xml/System/Uri.xml | 88 +++++++++++++++++--
7 files changed, 239 insertions(+), 9 deletions(-)
create mode 100644 snippets/csharp/System/Uri/HostComparison/Project.csproj
create mode 100644 snippets/csharp/System/Uri/HostComparison/source.cs
create mode 100644 snippets/fsharp/System/Uri/HostComparison/Project.csproj
create mode 100644 snippets/fsharp/System/Uri/HostComparison/source.fs
create mode 100644 snippets/visualbasic/System/Uri/HostComparison/Project.csproj
create mode 100644 snippets/visualbasic/System/Uri/HostComparison/source.vb
diff --git a/snippets/csharp/System/Uri/HostComparison/Project.csproj b/snippets/csharp/System/Uri/HostComparison/Project.csproj
new file mode 100644
index 00000000000..dd4b56868ac
--- /dev/null
+++ b/snippets/csharp/System/Uri/HostComparison/Project.csproj
@@ -0,0 +1,6 @@
+
+
+ Exe
+ net8.0
+
+
diff --git a/snippets/csharp/System/Uri/HostComparison/source.cs b/snippets/csharp/System/Uri/HostComparison/source.cs
new file mode 100644
index 00000000000..83d079e9d60
--- /dev/null
+++ b/snippets/csharp/System/Uri/HostComparison/source.cs
@@ -0,0 +1,50 @@
+using System;
+
+public class UriHostComparison
+{
+ public static void Main()
+ {
+ //
+ // Demonstrate differences between Host, IdnHost, and DnsSafeHost.
+
+ // Example 1: Regular hostname (ASCII).
+ Console.WriteLine("Example 1: Regular ASCII hostname");
+ Uri uri1 = new Uri("http://www.contoso.com:8080/path");
+ Console.WriteLine($" Host: {uri1.Host}"); // www.contoso.com
+ Console.WriteLine($" IdnHost: {uri1.IdnHost}"); // www.contoso.com
+ Console.WriteLine($" DnsSafeHost: {uri1.DnsSafeHost}"); // www.contoso.com
+ Console.WriteLine();
+
+ // Example 2: International domain name (non-ASCII).
+ Console.WriteLine("Example 2: International domain name");
+ Uri uri2 = new Uri("http://münchen.de/path");
+ Console.WriteLine($" Host: {uri2.Host}"); // münchen.de (original)
+ Console.WriteLine($" IdnHost: {uri2.IdnHost}"); // xn--mnchen-3ya.de (punycode)
+ Console.WriteLine($" DnsSafeHost: {uri2.DnsSafeHost}"); // depends on configuration
+ Console.WriteLine();
+
+ // Example 3: IPv6 address without zone ID.
+ Console.WriteLine("Example 3: IPv6 address without zone ID");
+ Uri uri3 = new Uri("http://[::1]:8080/path");
+ Console.WriteLine($" Host: {uri3.Host}"); // [::1] (with brackets)
+ Console.WriteLine($" IdnHost: {uri3.IdnHost}"); // ::1 (without brackets)
+ Console.WriteLine($" DnsSafeHost: {uri3.DnsSafeHost}"); // ::1 (without brackets)
+ Console.WriteLine();
+
+ // Example 4: IPv6 link-local address with zone ID.
+ Console.WriteLine("Example 4: IPv6 link-local address with zone ID");
+ Uri uri4 = new Uri("http://[fe80::1%10]:8080/path");
+ Console.WriteLine($" Host: {uri4.Host}"); // [fe80::1] (with brackets, no zone ID)
+ Console.WriteLine($" IdnHost: {uri4.IdnHost}"); // fe80::1%10 (without brackets, with zone ID)
+ Console.WriteLine($" DnsSafeHost: {uri4.DnsSafeHost}"); // fe80::1%10 (without brackets, with zone ID)
+ Console.WriteLine();
+
+ // Example 5: IPv4 address.
+ Console.WriteLine("Example 5: IPv4 address");
+ Uri uri5 = new Uri("http://192.168.1.1:8080/path");
+ Console.WriteLine($" Host: {uri5.Host}"); // 192.168.1.1
+ Console.WriteLine($" IdnHost: {uri5.IdnHost}"); // 192.168.1.1
+ Console.WriteLine($" DnsSafeHost: {uri5.DnsSafeHost}"); // 192.168.1.1
+ //
+ }
+}
diff --git a/snippets/fsharp/System/Uri/HostComparison/Project.csproj b/snippets/fsharp/System/Uri/HostComparison/Project.csproj
new file mode 100644
index 00000000000..dd4b56868ac
--- /dev/null
+++ b/snippets/fsharp/System/Uri/HostComparison/Project.csproj
@@ -0,0 +1,6 @@
+
+
+ Exe
+ net8.0
+
+
diff --git a/snippets/fsharp/System/Uri/HostComparison/source.fs b/snippets/fsharp/System/Uri/HostComparison/source.fs
new file mode 100644
index 00000000000..06e0e7e21e7
--- /dev/null
+++ b/snippets/fsharp/System/Uri/HostComparison/source.fs
@@ -0,0 +1,44 @@
+open System
+
+//
+// Demonstrate differences between Host, IdnHost, and DnsSafeHost.
+
+// Example 1: Regular hostname (ASCII).
+printfn "Example 1: Regular ASCII hostname"
+let uri1 = Uri("http://www.contoso.com:8080/path")
+printfn $" Host: {uri1.Host}" // www.contoso.com
+printfn $" IdnHost: {uri1.IdnHost}" // www.contoso.com
+printfn $" DnsSafeHost: {uri1.DnsSafeHost}" // www.contoso.com
+printfn ""
+
+// Example 2: International domain name (non-ASCII).
+printfn "Example 2: International domain name"
+let uri2 = Uri("http://münchen.de/path")
+printfn $" Host: {uri2.Host}" // münchen.de (original)
+printfn $" IdnHost: {uri2.IdnHost}" // xn--mnchen-3ya.de (punycode)
+printfn $" DnsSafeHost: {uri2.DnsSafeHost}" // depends on configuration
+printfn ""
+
+// Example 3: IPv6 address without zone ID.
+printfn "Example 3: IPv6 address without zone ID"
+let uri3 = Uri("http://[::1]:8080/path")
+printfn $" Host: {uri3.Host}" // [::1] (with brackets)
+printfn $" IdnHost: {uri3.IdnHost}" // ::1 (without brackets)
+printfn $" DnsSafeHost: {uri3.DnsSafeHost}" // ::1 (without brackets)
+printfn ""
+
+// Example 4: IPv6 link-local address with zone ID.
+printfn "Example 4: IPv6 link-local address with zone ID"
+let uri4 = Uri("http://[fe80::1%10]:8080/path")
+printfn $" Host: {uri4.Host}" // [fe80::1] (with brackets, no zone ID)
+printfn $" IdnHost: {uri4.IdnHost}" // fe80::1%10 (without brackets, with zone ID)
+printfn $" DnsSafeHost: {uri4.DnsSafeHost}" // fe80::1%10 (without brackets, with zone ID)
+printfn ""
+
+// Example 5: IPv4 address.
+printfn "Example 5: IPv4 address"
+let uri5 = Uri("http://192.168.1.1:8080/path")
+printfn $" Host: {uri5.Host}" // 192.168.1.1
+printfn $" IdnHost: {uri5.IdnHost}" // 192.168.1.1
+printfn $" DnsSafeHost: {uri5.DnsSafeHost}" // 192.168.1.1
+//
diff --git a/snippets/visualbasic/System/Uri/HostComparison/Project.csproj b/snippets/visualbasic/System/Uri/HostComparison/Project.csproj
new file mode 100644
index 00000000000..dd4b56868ac
--- /dev/null
+++ b/snippets/visualbasic/System/Uri/HostComparison/Project.csproj
@@ -0,0 +1,6 @@
+
+
+ Exe
+ net8.0
+
+
diff --git a/snippets/visualbasic/System/Uri/HostComparison/source.vb b/snippets/visualbasic/System/Uri/HostComparison/source.vb
new file mode 100644
index 00000000000..77189c25272
--- /dev/null
+++ b/snippets/visualbasic/System/Uri/HostComparison/source.vb
@@ -0,0 +1,48 @@
+Imports System
+
+Public Class UriHostComparison
+ Public Shared Sub Main()
+ '
+ ' Demonstrate differences between Host, IdnHost, and DnsSafeHost.
+
+ ' Example 1: Regular hostname (ASCII).
+ Console.WriteLine("Example 1: Regular ASCII hostname")
+ Dim uri1 As New Uri("http://www.contoso.com:8080/path")
+ Console.WriteLine($" Host: {uri1.Host}") ' www.contoso.com
+ Console.WriteLine($" IdnHost: {uri1.IdnHost}") ' www.contoso.com
+ Console.WriteLine($" DnsSafeHost: {uri1.DnsSafeHost}") ' www.contoso.com
+ Console.WriteLine()
+
+ ' Example 2: International domain name (non-ASCII).
+ Console.WriteLine("Example 2: International domain name")
+ Dim uri2 As New Uri("http://münchen.de/path")
+ Console.WriteLine($" Host: {uri2.Host}") ' münchen.de (original)
+ Console.WriteLine($" IdnHost: {uri2.IdnHost}") ' xn--mnchen-3ya.de (punycode)
+ Console.WriteLine($" DnsSafeHost: {uri2.DnsSafeHost}") ' depends on configuration
+ Console.WriteLine()
+
+ ' Example 3: IPv6 address without zone ID.
+ Console.WriteLine("Example 3: IPv6 address without zone ID")
+ Dim uri3 As New Uri("http://[::1]:8080/path")
+ Console.WriteLine($" Host: {uri3.Host}") ' [::1] (with brackets)
+ Console.WriteLine($" IdnHost: {uri3.IdnHost}") ' ::1 (without brackets)
+ Console.WriteLine($" DnsSafeHost: {uri3.DnsSafeHost}") ' ::1 (without brackets)
+ Console.WriteLine()
+
+ ' Example 4: IPv6 link-local address with zone ID.
+ Console.WriteLine("Example 4: IPv6 link-local address with zone ID")
+ Dim uri4 As New Uri("http://[fe80::1%10]:8080/path")
+ Console.WriteLine($" Host: {uri4.Host}") ' [fe80::1] (with brackets, no zone ID)
+ Console.WriteLine($" IdnHost: {uri4.IdnHost}") ' fe80::1%10 (without brackets, with zone ID)
+ Console.WriteLine($" DnsSafeHost: {uri4.DnsSafeHost}") ' fe80::1%10 (without brackets, with zone ID)
+ Console.WriteLine()
+
+ ' Example 5: IPv4 address.
+ Console.WriteLine("Example 5: IPv4 address")
+ Dim uri5 As New Uri("http://192.168.1.1:8080/path")
+ Console.WriteLine($" Host: {uri5.Host}") ' 192.168.1.1
+ Console.WriteLine($" IdnHost: {uri5.IdnHost}") ' 192.168.1.1
+ Console.WriteLine($" DnsSafeHost: {uri5.DnsSafeHost}") ' 192.168.1.1
+ '
+ End Sub
+End Class
diff --git a/xml/System/Uri.xml b/xml/System/Uri.xml
index a23c410227e..7a8413f03cf 100644
--- a/xml/System/Uri.xml
+++ b/xml/System/Uri.xml
@@ -1553,16 +1553,28 @@ The URI formed by combining and property is set, if one was specified when this instance was constructed.
-If you used an escaped string to construct this instance (for example, `"http://[fe80::200:39ff:fe36:1a2d%254]/temp/example.htm"`), then DnsSafeHost returns an escaped string. Unescape any escaped string returned from `DnsSafeHost` before using that string for DNS resolution (see the Example). If you used an invalid unescaped string to construct this instance (for example, "http://[fe80::200:39ff:fe36:1a2d%4]/temp/example.htm"), then DnsSafeHost returns an unescaped string.
+If you used an escaped string to construct this instance (for example, `"http://[fe80::200:39ff:fe36:1a2d%254]/temp/example.htm"`), then returns an escaped string. Unescape any escaped string returned from `DnsSafeHost` before using that string for DNS resolution (see the Example). If you used an invalid unescaped string to construct this instance (for example, "http://[fe80::200:39ff:fe36:1a2d%4]/temp/example.htm"), then returns an unescaped string.
- The property is dependent on configuration settings in .NET Framework apps, as discussed later in this topic. The property is provided as the preferred alternative to using , because is guaranteed to always be DNS safe.
+## Comparison with other Host properties
+
+ The class provides three host properties that serve different purposes:
+
+ - : Returns the escaped input as provided in the URI. For IPv6, includes brackets but not the zone ID.
+ - : Returns a DNS-safe representation. Non-ASCII hostnames are punycode encoded. For IPv6, doesn't include brackets but does include the zone ID.
+ - : Legacy property that behaves similarly to but depends on app configuration. Use instead.
+
+ Which property to use depends on your scenario:
+ - Use when you need the original host string as it appears in the URI (for display or comparison).
+ - Use when you need a DNS-safe format (for DNS resolution or APIs that require punycode).
+
+ The property is dependent on configuration settings in .NET Framework apps, as discussed later in this topic. The property is provided as the preferred alternative to using because is guaranteed to always be DNS safe.
The property was extended in .NET Framework v3.5, 3.0 SP1, and 2.0 SP1 to provide International Resource Identifier (IRI) support based on RFC 3987. However, to ensure application compatibility with prior versions, you must specifically enable it in .NET Framework apps. To enable support for IRI, the following two changes are required:
@@ -1597,14 +1609,14 @@ If you used an escaped string to construct this instance (for example, `"http://
- idn enabled = None
- This value will not convert any Unicode domain names to use Punycode. This is the default value, which is consistent with the .NET Framework 2.0 behavior.
+ This value won't convert any Unicode domain names to use Punycode. This is the default value, which is consistent with the .NET Framework 2.0 behavior.
Enabling IRI parsing (iriParsing enabled = `true`) normalizes and checks characters according to the IRI rules in RFC 3987. The default value is `false` and normalizes and checks characters according to RFC 2396 and RFC 2732 (for IPv6 literals).
For more information on IRI support, see the Remarks section for the class.
## Examples
- The following example creates a instance from a string. It illustrates the difference between the value returned from , which returns the host name or address specified in the URI, and the value returned from , which returns an address that is safe to use in DNS resolution.
+ The following example creates a instance from a string. It illustrates the difference between the value returned from , which returns the host name or address specified in the URI, and the value returned from , which returns an address that's safe to use in DNS resolution.
:::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/nclurienhancements.cs" id="Snippet4":::
:::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs" id="Snippet4":::
@@ -1612,6 +1624,12 @@ If you used an escaped string to construct this instance (for example, `"http://
As explained in Remarks, unescape the host name before resolving it. You can use the method to unescape the host name, and you can resolve it by calling the method.
+ The following example demonstrates the differences between , , and for various URI types:
+
+ :::code language="csharp" source="~/snippets/csharp/System/Uri/HostComparison/source.cs" id="SnippetHostComparison":::
+ :::code language="fsharp" source="~/snippets/fsharp/System/Uri/HostComparison/source.fs" id="SnippetHostComparison":::
+ :::code language="vb" source="~/snippets/visualbasic/System/Uri/HostComparison/source.vb" id="SnippetHostComparison":::
+
]]>
This instance represents a relative URI, and this property is valid only for absolute URIs.
@@ -2605,7 +2623,25 @@ The following examples show a URI and the results of calling property, this property value does not include the port number.
+ Unlike the property, this property value doesn't include the port number.
+
+ The behavior of this property depends on the host type:
+
+ - For **regular DNS hostnames**: Returns the escaped input. Non-ASCII characters are returned as-is without punycode encoding.
+ - For **IPv6 addresses**: Returns the address with square brackets (for example, `[::1]` or `[fe80::1]`) but doesn't include the zone ID (scope) even if one was specified in the original URI.
+ - For **IPv4 addresses**: Returns the dotted-decimal notation (for example, `192.168.1.1`).
+
+## Comparison with other Host properties
+
+ The class provides three host properties that serve different purposes:
+
+ - : Returns the escaped input as provided in the URI. For IPv6, includes brackets but not the zone ID.
+ - : Returns a DNS-safe representation. Non-ASCII hostnames are punycode encoded. For IPv6, doesn't include brackets but does include the zone ID.
+ - : Legacy property that behaves similarly to but depends on app configuration. Use instead.
+
+ Which property to use depends on your scenario:
+ - Use when you need the original host string as it appears in the URI (for display or comparison).
+ - Use when you need a DNS-safe format (for DNS resolution or APIs that require punycode).
## Examples
The following example writes the host name (`www.contoso.com`) of the server to the console.
@@ -2614,6 +2650,12 @@ The following examples show a URI and the results of calling , , and for various URI types:
+
+ :::code language="csharp" source="~/snippets/csharp/System/Uri/HostComparison/source.cs" id="SnippetHostComparison":::
+ :::code language="fsharp" source="~/snippets/fsharp/System/Uri/HostComparison/source.fs" id="SnippetHostComparison":::
+ :::code language="vb" source="~/snippets/visualbasic/System/Uri/HostComparison/source.vb" id="SnippetHostComparison":::
+
]]>
This instance represents a relative URI, and this property is valid only for absolute URIs.
@@ -2718,11 +2760,39 @@ The following examples show a URI and the results of calling for the hostname.
+ This property is provided for use with lower-level networking protocols that require the domain name in Punycode form or need DNS-safe formatting.
+
+ The behavior of this property depends on the host type:
+
+ - For **regular DNS hostnames**: Non-ASCII characters are punycode encoded (for example, `münchen.de` becomes `xn--mnchen-3ya.de`).
+ - For **IPv6 addresses**: Returns the address without square brackets but includes the zone ID (scope) if one was specified (for example, `::1` or `fe80::1%18`).
+ - For **IPv4 addresses**: Returns the dotted-decimal notation (for example, `192.168.1.1`).
+
+## Comparison with other Host properties
+
+ The class provides three host properties that serve different purposes:
+
+ - : Returns the escaped input as provided in the URI. For IPv6, includes brackets but not the zone ID.
+ - : Returns a DNS-safe representation. Non-ASCII hostnames are punycode encoded. For IPv6, doesn't include brackets but does include the zone ID.
+ - : Legacy property that behaves similarly to but depends on app configuration. Use instead.
+
+ Which property to use depends on your scenario:
+ - Use when you need the original host string as it appears in the URI (for display or comparison).
+ - Use when you need a DNS-safe format (for DNS resolution or APIs that require punycode).
+
+ The deprecated property is dependent on *app.config* settings, which can't be changed by Windows Store applications. is provided as the preferred alternative to using because is guaranteed to always be DNS safe, no matter what the current *app.config* settings might be.
+
+## Escaping behavior
+
+ If you used an escaped string to construct this instance (for example, `"http://[fe80::200:39ff:fe36:1a2d%254]/temp/example.htm"`), then returns an escaped string. You should unescape any escaped string returned from before using that string for DNS resolution. Be aware that if you used an invalid unescaped string to construct this instance (for example, "http://[fe80::200:39ff:fe36:1a2d%4]/temp/example.htm"), then returns an unescaped string.
+
+## Examples
- The deprecated property is dependent on *app.config* settings, which cannot be changed by Windows Store applications. IdnHost is provided as the preferred alternative to using , because is guaranteed to always be DNS safe, no matter what the current *app.config* settings might be.
+ The following example demonstrates the differences between , , and for various URI types:
- If you used an escaped string to construct this instance (for example, `"http://[fe80::200:39ff:fe36:1a2d%254]/temp/example.htm"`), then IdnHost returns an escaped string. You should unescape any escaped string returned from IdnHost before using that string for DNS resolution. Be aware that if you used an invalid unescaped string to construct this instance (for example, "http://[fe80::200:39ff:fe36:1a2d%4]/temp/example.htm"), then IdnHost returns an unescaped string.
+ :::code language="csharp" source="~/snippets/csharp/System/Uri/HostComparison/source.cs" id="SnippetHostComparison":::
+ :::code language="fsharp" source="~/snippets/fsharp/System/Uri/HostComparison/source.fs" id="SnippetHostComparison":::
+ :::code language="vb" source="~/snippets/visualbasic/System/Uri/HostComparison/source.vb" id="SnippetHostComparison":::
]]>
From 2ef2e874d97e90ede68077105bd6672ae6069712 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 10 Feb 2026 14:16:19 +0000
Subject: [PATCH 3/4] Fix project files for VB and F# snippets
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
---
.../System/Uri/HostComparison/HostComparison.fsproj} | 4 ++++
.../System/Uri/HostComparison/HostComparison.vbproj} | 1 +
2 files changed, 5 insertions(+)
rename snippets/{visualbasic/System/Uri/HostComparison/Project.csproj => fsharp/System/Uri/HostComparison/HostComparison.fsproj} (70%)
rename snippets/{fsharp/System/Uri/HostComparison/Project.csproj => visualbasic/System/Uri/HostComparison/HostComparison.vbproj} (76%)
diff --git a/snippets/visualbasic/System/Uri/HostComparison/Project.csproj b/snippets/fsharp/System/Uri/HostComparison/HostComparison.fsproj
similarity index 70%
rename from snippets/visualbasic/System/Uri/HostComparison/Project.csproj
rename to snippets/fsharp/System/Uri/HostComparison/HostComparison.fsproj
index dd4b56868ac..2bc0c95679c 100644
--- a/snippets/visualbasic/System/Uri/HostComparison/Project.csproj
+++ b/snippets/fsharp/System/Uri/HostComparison/HostComparison.fsproj
@@ -3,4 +3,8 @@
Exe
net8.0
+
+
+
+
diff --git a/snippets/fsharp/System/Uri/HostComparison/Project.csproj b/snippets/visualbasic/System/Uri/HostComparison/HostComparison.vbproj
similarity index 76%
rename from snippets/fsharp/System/Uri/HostComparison/Project.csproj
rename to snippets/visualbasic/System/Uri/HostComparison/HostComparison.vbproj
index dd4b56868ac..bcc781c5498 100644
--- a/snippets/fsharp/System/Uri/HostComparison/Project.csproj
+++ b/snippets/visualbasic/System/Uri/HostComparison/HostComparison.vbproj
@@ -2,5 +2,6 @@
Exe
net8.0
+ HostComparison
From d67ef0dabba504674c588a35a0fe583347a20f7b Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 10 Feb 2026 14:34:45 +0000
Subject: [PATCH 4/4] Refine Host documentation: C#-only examples, clarify
IdnHost behavior
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
---
.../System/Uri/HostComparison/source.cs | 2 +-
.../Uri/HostComparison/HostComparison.fsproj | 10 ----
.../System/Uri/HostComparison/source.fs | 44 -----------------
.../Uri/HostComparison/HostComparison.vbproj | 7 ---
.../System/Uri/HostComparison/source.vb | 48 ------------------
xml/System/Uri.xml | 49 +++++++------------
6 files changed, 18 insertions(+), 142 deletions(-)
delete mode 100644 snippets/fsharp/System/Uri/HostComparison/HostComparison.fsproj
delete mode 100644 snippets/fsharp/System/Uri/HostComparison/source.fs
delete mode 100644 snippets/visualbasic/System/Uri/HostComparison/HostComparison.vbproj
delete mode 100644 snippets/visualbasic/System/Uri/HostComparison/source.vb
diff --git a/snippets/csharp/System/Uri/HostComparison/source.cs b/snippets/csharp/System/Uri/HostComparison/source.cs
index 83d079e9d60..38be1206f6b 100644
--- a/snippets/csharp/System/Uri/HostComparison/source.cs
+++ b/snippets/csharp/System/Uri/HostComparison/source.cs
@@ -20,7 +20,7 @@ public static void Main()
Uri uri2 = new Uri("http://münchen.de/path");
Console.WriteLine($" Host: {uri2.Host}"); // münchen.de (original)
Console.WriteLine($" IdnHost: {uri2.IdnHost}"); // xn--mnchen-3ya.de (punycode)
- Console.WriteLine($" DnsSafeHost: {uri2.DnsSafeHost}"); // depends on configuration
+ Console.WriteLine($" DnsSafeHost: {uri2.DnsSafeHost}"); // münchen.de
Console.WriteLine();
// Example 3: IPv6 address without zone ID.
diff --git a/snippets/fsharp/System/Uri/HostComparison/HostComparison.fsproj b/snippets/fsharp/System/Uri/HostComparison/HostComparison.fsproj
deleted file mode 100644
index 2bc0c95679c..00000000000
--- a/snippets/fsharp/System/Uri/HostComparison/HostComparison.fsproj
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- Exe
- net8.0
-
-
-
-
-
-
diff --git a/snippets/fsharp/System/Uri/HostComparison/source.fs b/snippets/fsharp/System/Uri/HostComparison/source.fs
deleted file mode 100644
index 06e0e7e21e7..00000000000
--- a/snippets/fsharp/System/Uri/HostComparison/source.fs
+++ /dev/null
@@ -1,44 +0,0 @@
-open System
-
-//
-// Demonstrate differences between Host, IdnHost, and DnsSafeHost.
-
-// Example 1: Regular hostname (ASCII).
-printfn "Example 1: Regular ASCII hostname"
-let uri1 = Uri("http://www.contoso.com:8080/path")
-printfn $" Host: {uri1.Host}" // www.contoso.com
-printfn $" IdnHost: {uri1.IdnHost}" // www.contoso.com
-printfn $" DnsSafeHost: {uri1.DnsSafeHost}" // www.contoso.com
-printfn ""
-
-// Example 2: International domain name (non-ASCII).
-printfn "Example 2: International domain name"
-let uri2 = Uri("http://münchen.de/path")
-printfn $" Host: {uri2.Host}" // münchen.de (original)
-printfn $" IdnHost: {uri2.IdnHost}" // xn--mnchen-3ya.de (punycode)
-printfn $" DnsSafeHost: {uri2.DnsSafeHost}" // depends on configuration
-printfn ""
-
-// Example 3: IPv6 address without zone ID.
-printfn "Example 3: IPv6 address without zone ID"
-let uri3 = Uri("http://[::1]:8080/path")
-printfn $" Host: {uri3.Host}" // [::1] (with brackets)
-printfn $" IdnHost: {uri3.IdnHost}" // ::1 (without brackets)
-printfn $" DnsSafeHost: {uri3.DnsSafeHost}" // ::1 (without brackets)
-printfn ""
-
-// Example 4: IPv6 link-local address with zone ID.
-printfn "Example 4: IPv6 link-local address with zone ID"
-let uri4 = Uri("http://[fe80::1%10]:8080/path")
-printfn $" Host: {uri4.Host}" // [fe80::1] (with brackets, no zone ID)
-printfn $" IdnHost: {uri4.IdnHost}" // fe80::1%10 (without brackets, with zone ID)
-printfn $" DnsSafeHost: {uri4.DnsSafeHost}" // fe80::1%10 (without brackets, with zone ID)
-printfn ""
-
-// Example 5: IPv4 address.
-printfn "Example 5: IPv4 address"
-let uri5 = Uri("http://192.168.1.1:8080/path")
-printfn $" Host: {uri5.Host}" // 192.168.1.1
-printfn $" IdnHost: {uri5.IdnHost}" // 192.168.1.1
-printfn $" DnsSafeHost: {uri5.DnsSafeHost}" // 192.168.1.1
-//
diff --git a/snippets/visualbasic/System/Uri/HostComparison/HostComparison.vbproj b/snippets/visualbasic/System/Uri/HostComparison/HostComparison.vbproj
deleted file mode 100644
index bcc781c5498..00000000000
--- a/snippets/visualbasic/System/Uri/HostComparison/HostComparison.vbproj
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- Exe
- net8.0
- HostComparison
-
-
diff --git a/snippets/visualbasic/System/Uri/HostComparison/source.vb b/snippets/visualbasic/System/Uri/HostComparison/source.vb
deleted file mode 100644
index 77189c25272..00000000000
--- a/snippets/visualbasic/System/Uri/HostComparison/source.vb
+++ /dev/null
@@ -1,48 +0,0 @@
-Imports System
-
-Public Class UriHostComparison
- Public Shared Sub Main()
- '
- ' Demonstrate differences between Host, IdnHost, and DnsSafeHost.
-
- ' Example 1: Regular hostname (ASCII).
- Console.WriteLine("Example 1: Regular ASCII hostname")
- Dim uri1 As New Uri("http://www.contoso.com:8080/path")
- Console.WriteLine($" Host: {uri1.Host}") ' www.contoso.com
- Console.WriteLine($" IdnHost: {uri1.IdnHost}") ' www.contoso.com
- Console.WriteLine($" DnsSafeHost: {uri1.DnsSafeHost}") ' www.contoso.com
- Console.WriteLine()
-
- ' Example 2: International domain name (non-ASCII).
- Console.WriteLine("Example 2: International domain name")
- Dim uri2 As New Uri("http://münchen.de/path")
- Console.WriteLine($" Host: {uri2.Host}") ' münchen.de (original)
- Console.WriteLine($" IdnHost: {uri2.IdnHost}") ' xn--mnchen-3ya.de (punycode)
- Console.WriteLine($" DnsSafeHost: {uri2.DnsSafeHost}") ' depends on configuration
- Console.WriteLine()
-
- ' Example 3: IPv6 address without zone ID.
- Console.WriteLine("Example 3: IPv6 address without zone ID")
- Dim uri3 As New Uri("http://[::1]:8080/path")
- Console.WriteLine($" Host: {uri3.Host}") ' [::1] (with brackets)
- Console.WriteLine($" IdnHost: {uri3.IdnHost}") ' ::1 (without brackets)
- Console.WriteLine($" DnsSafeHost: {uri3.DnsSafeHost}") ' ::1 (without brackets)
- Console.WriteLine()
-
- ' Example 4: IPv6 link-local address with zone ID.
- Console.WriteLine("Example 4: IPv6 link-local address with zone ID")
- Dim uri4 As New Uri("http://[fe80::1%10]:8080/path")
- Console.WriteLine($" Host: {uri4.Host}") ' [fe80::1] (with brackets, no zone ID)
- Console.WriteLine($" IdnHost: {uri4.IdnHost}") ' fe80::1%10 (without brackets, with zone ID)
- Console.WriteLine($" DnsSafeHost: {uri4.DnsSafeHost}") ' fe80::1%10 (without brackets, with zone ID)
- Console.WriteLine()
-
- ' Example 5: IPv4 address.
- Console.WriteLine("Example 5: IPv4 address")
- Dim uri5 As New Uri("http://192.168.1.1:8080/path")
- Console.WriteLine($" Host: {uri5.Host}") ' 192.168.1.1
- Console.WriteLine($" IdnHost: {uri5.IdnHost}") ' 192.168.1.1
- Console.WriteLine($" DnsSafeHost: {uri5.DnsSafeHost}") ' 192.168.1.1
- '
- End Sub
-End Class
diff --git a/xml/System/Uri.xml b/xml/System/Uri.xml
index 7a8413f03cf..adb73c3221e 100644
--- a/xml/System/Uri.xml
+++ b/xml/System/Uri.xml
@@ -1564,15 +1564,12 @@ If you used an escaped string to construct this instance (for example, `"http://
## Comparison with other Host properties
- The class provides three host properties that serve different purposes:
+ The class provides two main host properties:
- - : Returns the escaped input as provided in the URI. For IPv6, includes brackets but not the zone ID.
- - : Returns a DNS-safe representation. Non-ASCII hostnames are punycode encoded. For IPv6, doesn't include brackets but does include the zone ID.
- - : Legacy property that behaves similarly to but depends on app configuration. Use instead.
+ - : Returns the host as it appears in the URI. For IPv6, includes brackets but not the zone ID.
+ - : Returns a format suitable for DNS resolution. For valid international domain names, applies punycode encoding. For IPv6, doesn't include brackets but does include the zone ID.
- Which property to use depends on your scenario:
- - Use when you need the original host string as it appears in the URI (for display or comparison).
- - Use when you need a DNS-safe format (for DNS resolution or APIs that require punycode).
+ The property is a legacy property that depends on configuration settings. Use instead for consistent, configuration-independent behavior.
The property is dependent on configuration settings in .NET Framework apps, as discussed later in this topic. The property is provided as the preferred alternative to using because is guaranteed to always be DNS safe.
@@ -1624,12 +1621,6 @@ If you used an escaped string to construct this instance (for example, `"http://
As explained in Remarks, unescape the host name before resolving it. You can use the method to unescape the host name, and you can resolve it by calling the method.
- The following example demonstrates the differences between , , and for various URI types:
-
- :::code language="csharp" source="~/snippets/csharp/System/Uri/HostComparison/source.cs" id="SnippetHostComparison":::
- :::code language="fsharp" source="~/snippets/fsharp/System/Uri/HostComparison/source.fs" id="SnippetHostComparison":::
- :::code language="vb" source="~/snippets/visualbasic/System/Uri/HostComparison/source.vb" id="SnippetHostComparison":::
-
]]>
This instance represents a relative URI, and this property is valid only for absolute URIs.
@@ -2631,17 +2622,16 @@ The following examples show a URI and the results of calling class provides three host properties that serve different purposes:
+ The class provides two main host properties:
- - : Returns the escaped input as provided in the URI. For IPv6, includes brackets but not the zone ID.
- - : Returns a DNS-safe representation. Non-ASCII hostnames are punycode encoded. For IPv6, doesn't include brackets but does include the zone ID.
- - : Legacy property that behaves similarly to but depends on app configuration. Use instead.
+ - : Returns the host as it appears in the URI. For IPv6, includes brackets but not the zone ID.
+ - : Returns a format suitable for DNS resolution. For valid international domain names, applies punycode encoding. For IPv6, doesn't include brackets but does include the zone ID.
Which property to use depends on your scenario:
- Use when you need the original host string as it appears in the URI (for display or comparison).
- - Use when you need a DNS-safe format (for DNS resolution or APIs that require punycode).
+ - Use when you need a format suitable for DNS resolution or network APIs.
## Examples
The following example writes the host name (`www.contoso.com`) of the server to the console.
@@ -2650,11 +2640,9 @@ The following examples show a URI and the results of calling , , and for various URI types:
+ The following example demonstrates the differences between and for various URI types:
:::code language="csharp" source="~/snippets/csharp/System/Uri/HostComparison/source.cs" id="SnippetHostComparison":::
- :::code language="fsharp" source="~/snippets/fsharp/System/Uri/HostComparison/source.fs" id="SnippetHostComparison":::
- :::code language="vb" source="~/snippets/visualbasic/System/Uri/HostComparison/source.vb" id="SnippetHostComparison":::
]]>
@@ -2764,21 +2752,20 @@ The following examples show a URI and the results of calling class provides three host properties that serve different purposes:
+ The class provides two main host properties:
- - : Returns the escaped input as provided in the URI. For IPv6, includes brackets but not the zone ID.
- - : Returns a DNS-safe representation. Non-ASCII hostnames are punycode encoded. For IPv6, doesn't include brackets but does include the zone ID.
- - : Legacy property that behaves similarly to but depends on app configuration. Use instead.
+ - : Returns the host as it appears in the URI. For IPv6, includes brackets but not the zone ID.
+ - : Returns a format suitable for DNS resolution. For valid international domain names, applies punycode encoding. For IPv6, doesn't include brackets but does include the zone ID.
Which property to use depends on your scenario:
- Use when you need the original host string as it appears in the URI (for display or comparison).
- - Use when you need a DNS-safe format (for DNS resolution or APIs that require punycode).
+ - Use when you need a format suitable for DNS resolution or network APIs.
The deprecated property is dependent on *app.config* settings, which can't be changed by Windows Store applications. is provided as the preferred alternative to using because is guaranteed to always be DNS safe, no matter what the current *app.config* settings might be.
@@ -2788,11 +2775,9 @@ The following examples show a URI and the results of calling , , and for various URI types:
+ The following example demonstrates the differences between and for various URI types:
:::code language="csharp" source="~/snippets/csharp/System/Uri/HostComparison/source.cs" id="SnippetHostComparison":::
- :::code language="fsharp" source="~/snippets/fsharp/System/Uri/HostComparison/source.fs" id="SnippetHostComparison":::
- :::code language="vb" source="~/snippets/visualbasic/System/Uri/HostComparison/source.vb" id="SnippetHostComparison":::
]]>