I'm trying to generate and download a pdf file. It keeps saying that the file type is wrong or that the file is damaged.
Here is my code
protected void downloadFile(int index)
{
string strContent = "<html> <body> <div> <b> Tjeu! </b> </div> <div> <INPUT TYPE=CHECKBOX NAME=\"maillist\" disabled=\"disabled\">Yes! Put me on the list! </div> </body> </html>";
string attach = "attachment; filename=wordtest.pdf";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentType = System.Net.Mime.MediaTypeNames.Application.Pdf;
HttpContext.Current.Response.AddHeader("content-disposition", attach);
HttpContext.Current.Response.Write(strContent);
HttpContext.Current.Response.End();
HttpContext.Current.Response.Flush();
}
Thx for the help ;)