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

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

iphone - How do I make a UIPickerView in a UIActionSheet -