通过HTTPS下载文件(C#)

时间:2011-03-03 19:17:42

标签: c# https download

我有一个表单,用户可以在其中附加word文档&保存在SQL DB上。检索这些文档在http上完美无缺,但在https上中断。我正在将文档存储在会话中。这是我检索文件的代码:

Attachments attach = AttachmentsSession[e.Item.ItemIndex] as Attachments;

string extension = attach.Extension;

byte[] bytFile = attach.AttachmentData;

Response.Clear();

Response.Buffer = true;

if (extension == ".doc")

{

    Response.ContentType = "application/vnd.ms-word";

    Response.AddHeader("content-disposition", "attachment;filename=" + attach.Name);

}

else if (extension == ".docx")

{

    Response.ContentType = "application/vnd.openxmlformats-
officedocument.wordprocessingml.document";

    Response.AddHeader("content-disposition", "attachment;filename=" + attach.Name);

}

Response.Charset = "";

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.BinaryWrite(bytFile);

HttpContext.Current.ApplicationInstance.CompleteRequest();

Response.End();

同样,它适用于http但不适用于https&该文档存储在SQL DB中。请帮忙

1 个答案:

答案 0 :(得分:0)

尝试通过HTTPS下载时是否收到错误消息?是否仅在使用IE时出现错误?如果是这样,请尝试更改“不保存加密页面”功能 IE高级设置。请参阅以下链接中的信息:http://www.ureader.com/msg/153060.aspx

相关问题