Note: This tutorial is based on .NET Framework 1.1, use C # language description, and assumes readers to understand HTML and C # syntax, JScript client scripts, know the basic IIS configuration. These do not belong to this tutorial, please refer to the relevant books or tutorials.
HTTP protocol
In addition to TCP / IP protocol, HTTP can be said to be the most important and use the most network protocol. This section briefly introduces the working principle of the HTTP protocol.
Suppose now has an HTML file: http.html, stored on the web server, its URL is
Www.myweb.com/http.html, the file content is:
HTML code:
hEAD>
Hello, http
body>
html>
Now, a user accesses the address by IE, IE first converts the domain name of this address into an IP address through the DNS, and then passes through a port of the web server (default is 80, not 80 to add ": port": port ", For example
Www.myweb.com:81) Connect, then transmit a similar information like this to download files like this (using FlashGet, etc.):
Code:
Get / http.html http / 1.1
Host: www.myweb.com
Accept: * / *
User-agent: mozilla / 4.0 (compatible; msie.6.0; windows NT 5.1)
Pragma: no-cache
Cache-Control: No-cache
Connection: Close
[Blade]
The first behavior request content, indicating that the resource request resources to the server via the GET method, / http.html is the request resource name, and HTTP / 1.1 represents the use of the HTTP protocol, version 1.1. Then the next few lines are called the header of the request information, which describes some other information requested, such as client browser identification, and the like. The last space indicates the end of the request.
When the web server receives the request, the server checks if the requested resource is valid, and whether there is corresponding permissions. If there is no problem, the server will return to the following HTTP response information:
Code:
HTTP / 1.1 200 ok
Server: Microsoft-IIS / 5.0
Date: Thursday, March 31, 2005 17:15:23 GMT
Content-Type: Text / HTML
Content-Length: 88
[Blade]
hEAD>
Hello, http
body>
html>
The "200" of the first line is a state code, indicating that the server successfully completed the request, if it is not successful, the other status code is returned. Content-type indicates the returned data type, and content-length indicates the returned data length. The blank representation header ends, the next is the data content returned by the browser, here is the file content of http.html, the browser parses the HTML source code, rendering the web page to the user, and completes a success here. HTTP communication.
The above content is the basis of web communication. Like the Windows message mechanism, you may not use it, but you have to know it, you have to know which low-level contents have hidden in those advanced things, so that you understand and use those Advanced things have a very helpful help :). 2. HTML FORM
The front http.html file is a simplest static HTML page, but as a web program, it is too simple, it does not accept user input, always display the same content. We need to be able to return the corresponding data according to user input.
Look at the HTML code below:
HTML code:
hEAD>