What's the difference between Uri.Host and Uri.Authority

Yes Brandon is absolutely correct, in layman terms

Authority = Host Name + Port No

And if URL protocol is using a default port, say port 80 for http URL, then only in that case Authority = Host Name (Port No is assumed to be 80),

Whereas Host Name is either Domain Name or I.P Address

Example:

  1. http://www.example.com/

    Authority = www.example.com
    Host Name = www.example.com

  2. http://255.255.255.255:8080/

    Authority = 255.255.255.255:8080
    Host Name = 255.255.255.255


From MSDN URI.Host page.

Unlike the Authority property, this property value does not include the port number.


Every HTTP URL conforms to the syntax of a generic URI. The URI generic syntax consists of a hierarchical sequence of five components:

URI = scheme:[//authority]path[?query][#fragment]

where the authority component divides into three subcomponents:

authority = [userinfo@]host[:port]

Like this:

wiki

An optional authority component preceded by two slashes (//), comprising:

  • An optional userinfo subcomponent that may consist of a user name and an optional password preceded by a colon (:), followed by an at symbol (@). Use of the format username:password in the userinfo subcomponent is deprecated for security reasons. Applications should not render as clear text any data after the first colon (:) found within a userinfo subcomponent unless the data after the colon is the empty string (indicating no password).
  • An optional host subcomponent, consisting of either a registered name (including but not limited to a hostname), or an IP address. IPv4 addresses must be in dot-decimal notation, and IPv6 addresses must be enclosed in brackets ([]).
  • An optional port subcomponent preceded by a colon (:).

For more details, you can refer to https://en.wikipedia.org/wiki/URL .

Tags:

C#

.Net

Uri