当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Generate PDF file from Byte[] over SSL

问题描述:

I have a web application (ASP.NET 4.0/C#) that allows the user to upload PDF files into the database (as Byte[]). When the user wants to view this PDF they select a link which calls a LoadDocument() function that returns the file in a Byte[].

private void createPDF(byte[] file, string Name)

{

int fileSize = file.Length;

Response.AppendHeader("content-length", fileSize.ToString());

Response.ContentType = "application/pdf";

if (!Name.Contains("."))

Name = Name + ".pdf";

Response.AddHeader("Content-Disposition", "attachment; filename="+ Name);

Response.BinaryWrite(file);

Response.Clear();

Response.Flush();

Response.End();

}

This was working fine, but once the website changed to SSL (it was running off of basic http for a while) I am now getting errors that say "Adobe Reader could not open 'Certificate[2].pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded).

This all happened around the time that 1)The site was changed to SSL 2)The network forced an upgrade to Adobe Reader X. How can I fix this?

EDIT: I have updated the code a bit thanks to suggestions below, still no avail though.

分享给朋友:
您可能感兴趣的文章:
随机阅读: