Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net

uri

System.Uri has Host, Authority, and DnsSafeHost. MS provides a nice example of when Host and DnsSafeHost are different here.

I'd like a similar example/explanation for Host and Authority.

like image 244
Brian Avatar asked Jan 26 '10 21:01

Brian


People also ask

What is URI authority?

URI Authorities is a part of the URI Scheme that holds an optional user-information part, terminated with "@" (e.g. username:password@); a hostname (e.g., domain name or IP Address); and an optional port, preceded by a colon ":".

What is URI host name?

The hostname property of the URL interface is a string containing the domain name of the URL.


1 Answers

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

like image 200
Saurabh Mishra Avatar answered Oct 20 '22 12:10

Saurabh Mishra