title: ASP.NET Download Handler Works in IE but not Chrome
body: <p>I have a download handler that will download the file when in IE but in chrome it attempts to download itself. By this I mean Chrome attempts to download a file called downloadhandler.ashx
  The code for the handler is</p>
  
  <pre><code>&lt;%@ WebHandler Language="C#" Class="DownloadHandler" %&gt;
  using System;
  using System.Web;
  
  public class DownloadHandler : IHttpHandler 
  {
  public void ProcessRequest(HttpContext context)
  {
      string file = "";
  
      // get the file name from the querystring
      if (context.Request.QueryString["Filepath"] != null)
      {
          file = context.Request.QueryString["Filepath"].ToString();
      }
  
      string filename = context.Server.MapPath("~/Minutes/" + file);
      System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename);
  
      try
      {
          if (fileInfo.Exists)
          {
              context.Response.Clear();
              context.Response.AddHeader("Content-Disposition", "inline;attachment; filename=\"" + fileInfo.Name + "\"");
              context.Response.AddHeader("Content-Length", fileInfo.Length.ToString());
              context.Response.ContentType = "application/octet-stream";
              context.Response.TransmitFile(fileInfo.FullName);
              context.Response.Flush();
          }
          else
          {
              throw new Exception("File not found");
          }
      }
      catch (Exception ex)
      {
          context.Response.ContentType = "text/plain";
          context.Response.Write(ex.Message);
      }
      finally
      {
          context.Response.End();
      }
  }
  
  public bool IsReusable
  {
      get
      {
          return false;
      }
  }
  
  
  
  }
  </code></pre>
  
  <p>The handler receives its information from this piece of code</p>
  
  <pre><code>private static string BuildAbsolute(string relativeUri)
  {
      // get current uri
      Uri uri = HttpContext.Current.Request.Url;
      // build absolute path
      string app = HttpContext.Current.Request.ApplicationPath;
      if (!app.EndsWith("/")) app += "/";
      relativeUri = relativeUri.TrimStart('/');
      // return the absolute path
      return HttpUtility.UrlPathEncode(
        String.Format("http://{0}:{1}{2}{3}",
        uri.Host, uri.Port, app, relativeUri));
  }
  </code></pre>
  
  <p>which is used in this method</p>
  
  <pre><code>public static string ToDownloadMinutes(string fileName)
  {
      return BuildAbsolute(String.Format("Handlers/DownloadHandler.ashx?Filepath={0}", fileName));
  }
  </code></pre>
  
  <p>Any help in getting this download functionality to work in Chrome would be greatly appreciated.</p>