【发布时间】:2011-04-25 18:50:29
【问题描述】:
我需要在浏览器中打开 docx 文件。尝试使用下面的代码。但是会发生文件损坏的错误。内容类型是否正确,也尝试使用内容类型 application/msword。
Response.AddHeader("content-disposition", "inline;filename=" + DisplayFileName); Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";//getContentType(filename); Response.WriteFile(fullpath); 响应。结束(); Response.Flush();
当给出适当的内容类型时,该代码适用于所有其他文件类型。问题只出在 docx 上。
【问题讨论】: