Windows 7 / Getting Started

Working with Data

Data management is an essential part of most modern Web sites. Imagine viewing a Web site that doesn't contain any graphics and uses a plain font. Most users will find such a Web site boring to the extreme. Of course, no one decided one day to create the multimedia extravaganzas presented by some Web sites today. Media and other data types have evolved as the Internet has grown. Consequently, you may sometimes find the rules for working with data on your Web site confusing and even contradictory at times. This section helps remove some of the confusion for you. You see how to work with data in three ways:

  • Multipurpose Internet Mail Extensions (MIME): Provides the caller with identifying information about the content that the server is sending. A MIME type tells the caller how to handle the data. The server also uses MIME types to discover how to handle data coming from the caller.
  • Request handlers: Simply because the caller provides a MIME type doesn't mean that the server knows how to handle the resulting input. A server must have a request handler that knows how to work with the data in question. You can install request handlers for any data type as long as the handler is written to support IIS 7.
  • Response modules: The server must also know how to send specific kinds of media to the caller. A response module tells the server how to perform this task in a standardized way (one in which the caller can react, assuming that the caller has the required capabilities). As with a request handler, you can install a response module to handle any kind of output as long as the module is written to support IIS 7.

Configuring MIME types

The MIME type for a document originally started as a way for e-mail programs to handle files that they didn't natively support. However, because MIME was originally introduced as a means of overcoming the limitations of text-based e-mail, it has found its way into a variety of applications, including the browser and even Windows. In short, setting the MIME type correctly is critical if you want IIS to provide the right support to the client. If you want to read about the internal workings of MIME, you can find the standard at http://www.faqs.org/rfcs/rfc2049.html. The following sections describe working with MIME in detail.

Understanding the basic MIME types

From the administrator's perspective, MIME types include a file extension and a string that tells what kind of application to use to handle the file. For example, the PDF file extension has a MIME type of application/pdf. The first part of the MIME type tells you that the system uses an application to handle the file, and the second part tells you that the application is the type assigned to the PDF file extension.

As another example, a WAV file, which contains a sound bite in most cases, uses the MIME type audio/wav. The first part specifies that this is an audio file and that the system should use the application responsible for WAV files to handle it. There's a very definite pattern to creating a MIME type - the file type comes first, followed by the handler type. The file types normally fall into the following categories:

Application 	Audio 		Example 	Image
Model 		Message 	Multipart 	Text
Video
Tip: Even though you define the MIME type within IIS, the user never actually sees it because the MIME type appears as part of the response header (see the "Handling HTTP Responses" section of this tutorial for details). A Web server always provides a complex response header that includes multiple MIME types because Web pages contain more than one kind of information. You can read more about how these response headers work at http://www.tcpipguide.com/free/t_MIMEBasicStructuresandHeaders.htm.

As previously mentioned, IIS defines a considerable number of common MIME types for you. To see the list of existing MIME types, select the connection you want to work with in the Connections pane and then double-click the MIME Types icons. You see a list of MIME types.

However, you might have to work with some uncommon MIME types. In this case, you can rely on a number of alternative sources to determine the MIME type to add to IIS. The first source you should consider is the vendor responsible for creating the file extension. Often, a vendor provides the information as part of the documentation for an application.

When a vendor source doesn't exist, you can always check the registry. Choose Start → Run, type RegEdit in the Open field, and then click OK. Locate the file extension you want to add in the HKEY_CLASSES_ROOT hive. The Content Type value in the right pane contains the MIME types for the file extension you choose.

In some cases, you won't have a local resource you can use. If the vendor who created the file extension has a Web site, you might be able to find the information there. You could also find the MIME type defined on one of many Web sites that provide a list of standardized MIME types, such as Internet Assigned Numbers Authority (IANA) at http://www.iana.org/assignments/media-types/ and LANTech at http://www.ltsw.se/knbase/internet/mime.htp.

Tip: If you truly can't find a MIME type for a particular file extension, you should register it with IANA at http://www.iana.org/cgi-bin/mediatypes.pl. This group verifies that the MIME type doesn't exist and adds it to its list if necessary. In no case should you ever make up a MIME type of your own and attempt to use it with a Web application. If everyone used this approach, chaos would result because each file could have multiple MIME types associated with it.
[Previous] [Contents] [Next]