Page #18 (Chapter 1 - Visual Basic and the Web)

Chapter 2 - IIS Applications

Visual Basic Developers Guide to ASP and IIS
A. Russell Jones
  Copyright 1999 SYBEX Inc.

How Browsers Request Files
When you type a Uniform Resource Locator (URL) into your browser's address field, many things happen. The browser parses the URL, sends a message to a Name server to translate the text name (for example, microsoft.com) into an Internet Protocol (IP) address (for example, 207.84.25.32). The browser then connects to the server with that IP address and requests the file. The server reads the file and sends the contents back to the browser. The browser parses the HTML, using the embedded commands to figure out how to format the file. Most HTML files contain references to graphics. These references are in the form of URLs as well, so the entire process repeats for each graphic reference, sometimes many times for files that contain many graphics or other file references.
So, the process of displaying an HTML file consists of a series of small transactions between the client (the browser) and the server (the Web server).
IIS applications work like the Web—in small transactions. First, a client browser makes a page request to the Web server. The request is always for a specific file. The server's response depends on the type of file requested. If the file is an HTML file (having an .htm or .html extension), the server simply reads the file contents, URL-encodes the content string, and then sends the encoded string back to the requesting browser. The entire process, from request to response, is a transaction between a client and a server. The client always initiates the transaction, then waits until the server returns a response, at which time the transaction is complete.
The file request to the Web server is similar to what happens when you double-click a network file in Windows Explorer, with two differences:
  The Web server never lets your local application (the browser) open or write to the requested file; instead, the Web server opens the file and returns the file contents.
  The connection is transient. You don't need to assign a drive letter to contact the Web server. After the Web server finishes processing your request, it disconnects.
As soon as the transaction is complete, the Web server forgets all about you. If you immediately click the Refresh button, the Web server simply repeats the transaction—it doesn't remember that you requested the file five seconds ago.
With a standard Hypertext Transfer Protocol (HTTP) connection, most Web files require several such transactions—one for the base HTML file, then one for each referenced graphic in that file. So to display a file with five embedded graphics, the browser makes six separate requests to the Web server (see Figure 2.1).
Note that in Figure 2.1 the first request is for an HTML file. The next five requests, for the graphics, are for a different file type (often referred to as the MIME type) that contains binary data. For each file type, both the server and the browser can treat the request and response differently. I won't explain all the MIME types right now; it's enough that you realize that browsers and Web servers respond differently to different kinds of files.
File extension associations control how IIS responds to file requests. These associations are stored in the Registry. This is the same method used by Windows Explorer to open the appropriate application when you double-click a file. With browsers, the MIME-type header returned by the server controls how the browser responds to different file types. MIME stands for Multipurpose Internet Mail Extensions. The server returns the file's MIME type with each request. Browsers use the MIME type header to determine how to display the file. In most cases (text/.html files, .gif files, and .jpg files), the browser can display the files directly. For other types, such as .doc and .avi, the browser will find the MIME type in a custom list, then launch the appropriate application to display the file.
  Note If you're interested in knowing more about MIME, you can find a list of all the registered types at http://www.isi.edu/in-notes/iana/assignments/media-types/media-types.



Visual Basic Developer[ap]s Guide to ASP and IIS
Visual Basic Developer[ap]s Guide to ASP and IIS
ISBN: 782125573
EAN: N/A
Year: 2005
Pages: 98

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net