title: asp.net ashx handler prompting download instead of displaying file
body: <p>I implemented a generic handler in my application which works great for images, but when I manually type the handler URL in the browser with the image's querystring it prompts download instead of displaying.  Here is my code:</p>
  
  <pre><code>public void ProcessRequest(HttpContext context)
          {
              if (this.FileName != null)
              {
                  string path = Path.Combine(ConfigurationManager.UploadsDirectory, this.FileName);
  
                  if (File.Exists(path) == true)
                  {
                      FileStream file = new FileStream(path, FileMode.Open);
                      byte[] buffer = new byte[(int)file.Length];
                      file.Read(buffer, 0, (int)file.Length);
                      file.Close();
                      context.Response.ContentType = "application/octet-stream";
                      context.Response.AddHeader("content-disposition", "attachment; filename=\"" + this.FileName + "\"");
                      context.Response.BinaryWrite(buffer);
                      context.Response.End();
                  }
              }
          }
  </code></pre>
  
  <p>I am using the octet-stream because I'm dealing with more than just images and I don't always know the content type of the file.  Thanks in advance!</p>