You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: xml/System/Uri.xml
+17-32Lines changed: 17 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -1564,15 +1564,12 @@ If you used an escaped string to construct this instance (for example, `"http://
1564
1564
1565
1565
## Comparison with other Host properties
1566
1566
1567
-
The <xref:System.Uri> class provides three host properties that serve different purposes:
1567
+
The <xref:System.Uri> class provides two main host properties:
1568
1568
1569
-
- <xref:System.Uri.Host%2A>: Returns the escaped input as provided in the URI. For IPv6, includes brackets but not the zone ID.
1570
-
- <xref:System.Uri.IdnHost%2A>: Returns a DNS-safe representation. Non-ASCII hostnames are punycode encoded. For IPv6, doesn't include brackets but does include the zone ID.
1571
-
- <xref:System.Uri.DnsSafeHost%2A>: Legacy property that behaves similarly to <xref:System.Uri.IdnHost%2A> but depends on app configuration. Use <xref:System.Uri.IdnHost%2A> instead.
1569
+
- <xref:System.Uri.Host%2A>: Returns the host as it appears in the URI. For IPv6, includes brackets but not the zone ID.
1570
+
- <xref:System.Uri.IdnHost%2A>: 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.
1572
1571
1573
-
Which property to use depends on your scenario:
1574
-
- Use <xref:System.Uri.Host%2A> when you need the original host string as it appears in the URI (for display or comparison).
1575
-
- Use <xref:System.Uri.IdnHost%2A> when you need a DNS-safe format (for DNS resolution or APIs that require punycode).
1572
+
The <xref:System.Uri.DnsSafeHost%2A> property is a legacy property that depends on configuration settings. Use <xref:System.Uri.IdnHost%2A> instead for consistent, configuration-independent behavior.
1576
1573
1577
1574
The <xref:System.Uri.DnsSafeHost%2A> property is dependent on configuration settings in .NET Framework apps, as discussed later in this topic. The <xref:System.Uri.IdnHost%2A> property is provided as the preferred alternative to using <xref:System.Uri.DnsSafeHost%2A> because <xref:System.Uri.IdnHost%2A> is guaranteed to always be DNS safe.
1578
1575
@@ -1624,12 +1621,6 @@ If you used an escaped string to construct this instance (for example, `"http://
1624
1621
1625
1622
As explained in Remarks, unescape the host name before resolving it. You can use the <xref:System.Uri.UnescapeDataString%2A> method to unescape the host name, and you can resolve it by calling the <xref:System.Net.Dns.GetHostEntry%2A> method.
1626
1623
1627
-
The following example demonstrates the differences between <xref:System.Uri.Host%2A>, <xref:System.Uri.IdnHost%2A>, and <xref:System.Uri.DnsSafeHost%2A> for various URI types:
<exceptioncref="T:System.InvalidOperationException">This instance represents a relative URI, and this property is valid only for absolute URIs.</exception>
@@ -2631,17 +2622,16 @@ The following examples show a URI and the results of calling <xref:System.Uri.Ge
2631
2622
- 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.
2632
2623
- For **IPv4 addresses**: Returns the dotted-decimal notation (for example, `192.168.1.1`).
2633
2624
2634
-
## Comparison with other Host properties
2625
+
## Comparison with IdnHost
2635
2626
2636
-
The <xref:System.Uri> class provides three host properties that serve different purposes:
2627
+
The <xref:System.Uri> class provides two main host properties:
2637
2628
2638
-
- <xref:System.Uri.Host%2A>: Returns the escaped input as provided in the URI. For IPv6, includes brackets but not the zone ID.
2639
-
- <xref:System.Uri.IdnHost%2A>: Returns a DNS-safe representation. Non-ASCII hostnames are punycode encoded. For IPv6, doesn't include brackets but does include the zone ID.
2640
-
- <xref:System.Uri.DnsSafeHost%2A>: Legacy property that behaves similarly to <xref:System.Uri.IdnHost%2A> but depends on app configuration. Use <xref:System.Uri.IdnHost%2A> instead.
2629
+
- <xref:System.Uri.Host%2A>: Returns the host as it appears in the URI. For IPv6, includes brackets but not the zone ID.
2630
+
- <xref:System.Uri.IdnHost%2A>: 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.
2641
2631
2642
2632
Which property to use depends on your scenario:
2643
2633
- Use <xref:System.Uri.Host%2A> when you need the original host string as it appears in the URI (for display or comparison).
2644
-
- Use <xref:System.Uri.IdnHost%2A> when you need a DNS-safe format (for DNS resolution or APIs that require punycode).
2634
+
- Use <xref:System.Uri.IdnHost%2A> when you need a format suitable for DNS resolution or network APIs.
2645
2635
2646
2636
## Examples
2647
2637
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 <xref:System.Uri.Ge
The following example demonstrates the differences between <xref:System.Uri.Host%2A>, <xref:System.Uri.IdnHost%2A>, and <xref:System.Uri.DnsSafeHost%2A> for various URI types:
2643
+
The following example demonstrates the differences between <xref:System.Uri.Host%2A>and <xref:System.Uri.IdnHost%2A> for various URI types:
@@ -2764,21 +2752,20 @@ The following examples show a URI and the results of calling <xref:System.Uri.Ge
2764
2752
2765
2753
The behavior of this property depends on the host type:
2766
2754
2767
-
- For **regular DNS hostnames**: Non-ASCII characters are punycode encoded (for example, `münchen.de` becomes `xn--mnchen-3ya.de`).
2755
+
- For **regular DNS hostnames**: For valid international domain names, non-ASCII characters are punycode encoded (for example, `münchen.de` becomes `xn--mnchen-3ya.de`). Invalid or malformed hostnames might return non-ASCII values.
2768
2756
- 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`).
2769
2757
- For **IPv4 addresses**: Returns the dotted-decimal notation (for example, `192.168.1.1`).
2770
2758
2771
-
## Comparison with other Host properties
2759
+
## Comparison with Host
2772
2760
2773
-
The <xref:System.Uri> class provides three host properties that serve different purposes:
2761
+
The <xref:System.Uri> class provides two main host properties:
2774
2762
2775
-
- <xref:System.Uri.Host%2A>: Returns the escaped input as provided in the URI. For IPv6, includes brackets but not the zone ID.
2776
-
- <xref:System.Uri.IdnHost%2A>: Returns a DNS-safe representation. Non-ASCII hostnames are punycode encoded. For IPv6, doesn't include brackets but does include the zone ID.
2777
-
- <xref:System.Uri.DnsSafeHost%2A>: Legacy property that behaves similarly to <xref:System.Uri.IdnHost%2A> but depends on app configuration. Use <xref:System.Uri.IdnHost%2A> instead.
2763
+
- <xref:System.Uri.Host%2A>: Returns the host as it appears in the URI. For IPv6, includes brackets but not the zone ID.
2764
+
- <xref:System.Uri.IdnHost%2A>: 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.
2778
2765
2779
2766
Which property to use depends on your scenario:
2780
2767
- Use <xref:System.Uri.Host%2A> when you need the original host string as it appears in the URI (for display or comparison).
2781
-
- Use <xref:System.Uri.IdnHost%2A> when you need a DNS-safe format (for DNS resolution or APIs that require punycode).
2768
+
- Use <xref:System.Uri.IdnHost%2A> when you need a format suitable for DNS resolution or network APIs.
2782
2769
2783
2770
The deprecated <xref:System.Uri.DnsSafeHost%2A> property is dependent on *app.config* settings, which can't be changed by Windows Store applications. <xref:System.Uri.IdnHost%2A> is provided as the preferred alternative to using <xref:System.Uri.DnsSafeHost%2A> because <xref:System.Uri.IdnHost%2A> is guaranteed to always be DNS safe, no matter what the current *app.config* settings might be.
2784
2771
@@ -2788,11 +2775,9 @@ The following examples show a URI and the results of calling <xref:System.Uri.Ge
2788
2775
2789
2776
## Examples
2790
2777
2791
-
The following example demonstrates the differences between <xref:System.Uri.Host%2A>, <xref:System.Uri.IdnHost%2A>, and <xref:System.Uri.DnsSafeHost%2A> for various URI types:
2778
+
The following example demonstrates the differences between <xref:System.Uri.Host%2A>and <xref:System.Uri.IdnHost%2A> for various URI types:
0 commit comments