如何在 Chrome 中打开 docx 而不是下载

时间:2021-01-05 15:22:26

标签: c# .net vb.net

我有代码可以在浏览器中打开 docx 文件。在 IE 上打开时,Microsoft Office Word 将打开而不保存。但是它不适用于 Edge 和 Chrome。当它在 Edge 或 Chrome 上打开时,它显示 about:blank,文件已下载并可以选择打开它。
我也按照 open docx in asp.net 使用 Response.WriteFile 而不是 Response.TransmitFile 但它不起作用。
有人能告诉我应该怎么做才能让它发挥作用吗?

这是我的代码:

Response.ClearHeaders()
Response.ClearContent()
Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
Response.TransmitFile(filePath)
Response.Flush()
Response.Close() 

0 个答案:

没有答案
相关问题