asp.net - docx文件不能在浏览器中打开,内容配置内联于 IE 8

我想从ASP.NET在ie中打开docx文件,IIS的mime类型已正确映射,我可以打开pdf,但docx文件总是会提示我下载,有什么设置要做?


 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或Word Viewer是否安装在测试机上?

如果处理应用程序不存在,浏览器没有选择,只能下载文件。

使用MSKB文章的说明进行检查

我通常按照以下格式强制用户使用文件:


Response.Clear()
Response.ClearHeaders()
Response.Buffer = True
Response.ContentType ="your mime type"
Response.CacheControl ="public"
Response.AddHeader("Pragma","public")
Response.AddHeader("Expires","0")
Response.AddHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0")
Response.AddHeader("Content-Description","Description of your content")
Response.AddHeader("Content-Disposition","attachment; filename=""somefile.pdf""")

Response.BinaryWrite(buffer)

Response.Flush()
Response.End()

http://stackoverflow.com/questions/179315/downloading-docx-from-ie-setting-mime-types-in-iishttp://blogs.msdn.com/b/vsofficedeveloper/archive/2008/05/08/office-2007-open-xml-mime-types.aspx

旧版ie 在SSL下存在这个问题


<outboundRules>
 <rule name="Always Remove Pragma Header">
 <match serverVariable="RESPONSE_Pragma" pattern="(.*)" />
 <action type="Rewrite" value="" />
 </rule>
 <rule name="Remove No-Store for Attachments">
 <conditions>
 <add input="{RESPONSE_Content-Disposition}" pattern="attachment" />
 </conditions>
 <match serverVariable="RESPONSE_Cache-Control" pattern="no-store" />
 <action type="Rewrite" value="max-age=0" />
 </rule>
</outboundRules>

...