I have a file on my server or well in this localhost. I want to transmit it to user using this code:
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=buylist.pdf");
Response.TransmitFile(Server.MapPath("~/buylist.pdf"));
Response.ContentType = "application/csv";
Response.AppendHeader("Content-Disposition", "attachment; filename=buylist.csv");
Response.TransmitFile(Server.MapPath("~/buylist.csv"));
I know the file I am trying to transmit our fine and I even tried adding Response.Close()
but each time the file is corrupted. The csv give me the page's HTML. I am really lost.