二进制文件下载 - 但下载的文件没有文件扩展名?

时间:2017-10-16 02:20:06

标签: c# asp.net

protected void getFileAttachment(byte[] bytes)
{
    Response.Clear();
    Response.Buffer = true;
    Response.Charset = "";
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = fileType;
    Response.AppendHeader("Content-Disposition", "attachment; filename=" + "test101");
    Response.OutputStream.Write(bytes,0,bytes.Length);
    Response.BinaryWrite(bytes);
    Response.Flush();
}
  

我正在尝试转换保存在SQL Server中的varbinary,但由于输出文件没有扩展名,我遇到了麻烦

1 个答案:

答案 0 :(得分:0)

Response.AppendHeader("Content-Disposition", "attachment; filename=" + "test101.filetype");
  

我的错 - 我没有在我的数据库中包含文件扩展名   感谢您的评论!