To provide file download Facility in ASP.Net




To provide file download facility to use in from the website the following code need to be done in the button click event




protected void Button1_Click(object sender, EventArgs e)
{
string path = Server.MapPath("html-character-entities-cheat-sheet.pdf");
string name = System.IO.Path.GetFileName(path);
Response.AppendHeader("content-disposition","attachment; filename=" + name);
Response.ContentType = "Application/pdf";
Response.WriteFile(path);
Response.End();
}



Comments

Popular posts from this blog

Export To Excel Even With Special Character in Data

Get Plain Text from FCKEditor in any Browser.