try { string contentType = ""; //Get the physical path to the file. string invoice = "~/Invoice/" + DropDownList1.SelectedItem.ToString() + ".pdf"; string FilePath = HttpContext.Current.Server.MapPath(invoice); string fileExt = Path.GetExtension(invoice).Split('.')[1].ToLower(); if (fileExt == "pdf") { //Set the appropriate ContentType. contentType = "Application/pdf"; } //Set the appropriate ContentType. Response.ContentType = contentType; Response.AppendHeader("content-disposition", "attachment; filename=" + (new FileInfo(invoice)).Name); //Write the file directly to the HTTP content output stream. Response.WriteFile(FilePath); Response.End(); } catch { //To Do }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)