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

To Move items from one ListBox to another Listbox

Receive Json Web response in C#