Introduction
Most of the time, has been learning C #, intends to take the net essence theory to learn a bit, although already looked at both sides, the total feeling has seen, did not take notes is equal to white, a little impression. Intend to write the code in the book, to realize it, in the code to always reflect on, why the author, if it is how to achieve?
Web application
Address of the resource-Universal Resource Identifier (URI)
What we enter in the browser address bar is collectively known as the Universal Resource Identifier (Universal Resource Identifier,uri), which has many forms, and in the web we typically use Uniform Resource Locators (Uniform Resource Locator) in the form of the following format:
Protocol://host [. Port number] [absolute path [? parameters]]
In the http://www.microsoft.com/en/us/default.aspx:
http: Represents the protocol name;
www.microsoft.com: Represents the address of the host; The default port number for the HTTP protocol is 80.
/en/us/default.aspx: Absolute path. There are no arguments to follow, and if you add more than one parameter, you can say the following:
/en/us/default.aspx?p=1&n=2
In. NET, both the URI and the URL are processed by the URI class that is defined in the System namespace.
The class defines 5 properties, which correspond to 5 components respectively.
Scheme attribute: The name of the protocol.
Host: Gets the hosts section in the URI address.
Port: Gets the port number.
Absolutepath: Absolute Path section.
The parameters section of the Query:uri address.
Simple example:
1System.Uri ms =NewUri ("http://www.microsoft.com/en/us/default.aspx");2Console.WriteLine ("protocol:"+Ms. Scheme);3Console.WriteLine ("Host:"+Ms. Host);4Console.WriteLine ("Port number:"+Ms. Port);5Console.WriteLine ("Absolute Path:"+Ms. Absolutepath);6Console.WriteLine ("Parameters:"+Ms. Query);7Console.read ();
Results:
How to find a host
Thousands of servers on the Internet, if you find one of the Internet, how to find it? It is like, although the world population as many as billions of, how to find someone, then you know his address, not to find more convenient and quick? Similarly, the browser to find the server, also need the network address of the server.
Under the current TCP/IP protocol, the so-called network address, is an IP address, currently we are using the IPV4 address, that is, the IP Protocol Fourth edition of the address, each address from four bytes total 32 bits. Theoretically, you can represent 4G network addresses. Format: 192.198.0.1, four numbers divided by dots, up to 255. For example, Microsoft's IP address: 207.46.19.254, you can also see the Web page by entering http://207.46.19.254 directly in the address bar.
But remembering numbers alone can be a headache, and it's easier to find a host with a meaningful name. In 1983, Paul Mockapetris invented the domain Name system, so that, on the Internet, we could make a meaningful name for the IP to make it easy to find a host, a name that Moka The domain name of the Microsoft Web server is www.microsoft.com, which corresponds to the actual IP address: 207.46.19.254
How does the domain name and IP correspond?
This work is done by the DNS of the domain name server, or domain name. The DNS server provides a hierarchical address book that allows the user to find the corresponding address through the domain name, or to find the corresponding domain name through the address. Usually, the Internet service provider has helped us set up the DNS server automatically, so we can easily find Microsoft Web server through the www.microsoft.com domain name.
Once you know the server, you need to transfer the request from our client to the server, so how does the two computers communicate? How can they understand the data they send to each other? That would require a reference to the agreement.
Summarize
URL format:
Protocol://host [. Port number] [absolute path [? parameters]]
In the Internet, the host is found through IP, and the domain name and IP address are associated with DNS.