Tuesday, 26 April 2011

Download Attachenment in asp.net

string fileName = lblOrderID.Text + ".pdf";
        string path = Server.MapPath("~/Invoice/") + fileName;
        FileInfo file = new FileInfo(path);
        if (file.Exists)
        {
            Response.ContentType = "application/pdf";
            Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
            Response.TransmitFile(path);
            Response.End();
        }

No comments:

Post a Comment