c# - PDF returning a corrupt file -


I am using the following bit code to redirect the PDF file to the user. It works fine on my PC and on all our test PCs even though the user is complaining that the document is corrupt. When I send the PDF file back to Notepad, I can see some HTML after binary information.

  protected void btnGetFile_Click (object sender, EventArgs e) {string title = "DischargeSummary.pdf"; String contentType = "app / pdf"; Byte [] documentBytes = GetDoc (DocID); Response.Clear (); Response.ContentType = contentType; Response.AddHeader ("content-nature", "attachment; file name =" + title); Response.BinaryWrite (documentBytes); }  

The problem is due to the response object attaching to the end of the file file Finally parsed HTML for the page.

  Safe void btnGetFile_Click (Object Sender, EventArgs e) {/ p> 

You have replied, then it can be stopped by calling Response.Close (). String Title = "Discharge Soumouree PDF"; String contentType = "app / pdf"; Byte [] documentBytes = GetDoc (DocID); Response.Clear (); Response.ContentType = contentType; Response.AddHeader ("content-nature", "attachment; file name =" + title); Response.BinaryWrite (documentBytes); Rispans.and (); }


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -