I have a web application in ASP.NET with C# and i am having an issue opening some PDF's.
The code looks up the selected ID and pulls the pdf path associated with that ID. The path that is being returned is working, and is correct. For some reason, when I hit open in the browser it says the file is corrupted and cannot be repaired, but when I open it in adobe everything is perfect.
Here is my code:
string id;
string path;
DataTable dt = Session["UnmatchedItems"] as DataTable;
ASPxButton button = (ASPxButton)sender;
id = button.CommandName;
DataView dv = new DataView(dt);
dv.RowFilter = "id = " + id;
path = dv[0][2].ToString();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=" + path);
Response.WriteFile(path);
Not sure what is going on or why it won't open...
If I forgot anything or you need more info, let me know!