Download PDF Document on Save as dialog
<p>I am using following code for downloading PDF document in save as mode but there is a problem in IE,
anyone can resolve this prohlem?</p>

<pre><code>private void DownloadFile(string fname, bool forceDownload)
{
    string path = MapPath(fname);
    string name = Path.GetFileName(fname);
    string ext = Path.GetExtension(fname);
    string type = "";
    Response.ClearHeaders();
    Response.ClearContent();
    // set known types based on file extension  
    if (ext != null)
    {
        switch (ext.ToLower())
        {
            case ".htm":
            case ".html":
                type = "text/HTML";
                break;

            case ".txt":
                type = "text/plain";
                break;

            case ".pdf":
               type = "application/pdf";
                break;
            case ".doc":
            case ".docx":
            case ".rtf":
                type = "Application/msword";
                break;
        }
    }
    if (forceDownload)
    {
        Response.AppendHeader("content-disposition", "attachment; filename=" + name);
    }
    if (type != "")
    {
        Response.ContentType = type;
        Response.WriteFile(path);
        Response.End();
    }

}
</code></pre>

<p>thanks</p>

<p>Asim Hashmi</p>
