title: Content Type when serving a file in a generic handler
body: <p>I'm busy writing a handler to serve various documents for download or presentation in web forms pages.  The documents range from various image formats, to PDF, to MS Office documents, to generic binaries.  My basic draft of the download process is as below:</p>
  
  <pre><code>public void ProcessRequest(HttpContext context)
  {
      var docUrl = context.Request["docUrl"];
      if (string.IsNullOrEmpty(docUrl)) {
          context.Response.End();
          return;
      }
      var docPath = context.Server.MapPath(docUrl);
      var docInfo = new FileInfo(docPath);
  
      context.Response.Clear();
      context.Response.AddHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(docPath));
      context.Response.AddHeader("Content-Length", docInfo.Length.ToString());
      context.Response.ContentType = "application/octet-stream";
      context.Response.WriteFile(docPath);
      context.Response.End();
  }
  </code></pre>
  
  <p>However, I have some misgivings about lumping all documents together as <code>application/octet-stream</code>, and I would prefer, if feasible, to use a more specific content type per document type.  I have a DB table for document types where I could store this.  Am I going in the right direction, and if so, where can I find a suitable starting list of content types for document types?</p>