我想从 asp.net 在 IE 中打开 docx 文件。 IIS 已正确映射 mime 类型。我可以很好地打开 pdf,但 docx 总是会提示我下载,例如 content-disposition='attachment'。有什么需要做的设置吗?
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Cookies.Clear();
Response.Cache.SetCacheability(HttpCacheability.Private);
Response.CacheControl = "private";
Response.Charset = System.Text.UTF8Encoding.UTF8.WebName;
Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
Response.AppendHeader("Content-Length", buffer.Length.ToString());
Response.AppendHeader("Pragma", "cache");
Response.AppendHeader("Expires", "60");
Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
Response.AppendHeader("Content-Disposition",
"inline; " +
"filename=\"" + "test.docx" + "\"; " +
"size=" + buffer.Length.ToString() + "; " +
"creation-date=" + DateTime.Now.ToString("R") + "; " +
"modification-date=" + DateTime.Now.ToString("R") + "; " +
"read-date=" + DateTime.Now.ToString("R"));
Response.BinaryWrite(buffer);
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
Response.End();
是 Microsoft Word 还是文字查看器 http://www.microsoft.com/downloads/details.aspx?FamilyID=3657ce88-7cfa-457a-9aec-f4f827f20cac安装在正在测试的计算机上?
如果处理应用程序不存在,浏览器将没有太多选择,只能下载文件。
如果安装了 Word,您可能还需要检查您的 Windows 文件类型是否将 .docx 映射到 Word、另一个应用程序或什么都没有。使用本中的说明进行检查MSKB 文章 http://support.microsoft.com/kb/307859
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)