在我的组织中,使用 MS Edge 作为默认浏览器,有一个定期更新且经常打开的 Excel 电子表格,我们将其托管在内部 IIS 服务器上,并从另一个内部 ASP.NET 网站链接到该电子表格,该网站也在IIS。 每次有人单击该链接时,该文件都会再次下载,并且必须在用户的 Excel 桌面副本中手动打开,即使 Edge 现在可以查看 MS Office 文件(通过 Office Web 应用程序)并且此设置由默认。 Edge 中的“在浏览器中打开 Office 文件”选项是否启用与发生的情况无关。拖放或按 Ctrl+O-ing 下载的文件只会使 Edge 再次“下载”它。
我的问题在这里:
- Edge 究竟如何决定它可以打开哪些 MS Office 文件?是否仅支持某些版本的 Office?我尝试了默认的 .xlsx 文件类型和 Office 97-2003 .xls,具有相同的效果;该文件可能没有任何格式错误或特殊,因为我的测试文件几乎是带有一个文本单元格的空电子表格
- 是否有某种机制可以强制浏览器尝试打开它支持的文件,类似于
download
的相反内容a
上的属性标签?Content-Disposition: inline
似乎是我正在寻找的内容,但是检查网络选项卡中的下载显示该 header 不存在,因此inline
应为默认值。 - 我曾考虑过嵌入 OneDrive 中存储的文档副本,但此功能似乎已被弃用。是这样吗?或者组织可以禁用它?
作为最后的手段,我们可以将文档存储为 PDF(本质上是只读的)。
尝试过:
- 使用 group policy/registry key 强制启用“在浏览器中打开 Office 文件”选项
- 只需打开文件链接
- 使用 Edge 打开本地存储的 Excel 文件
每个人都使用其 Microsoft 帐户登录 Office 365,我也看到这是一项要求。
期望:
- 使用 Edge 的 Office 查看器功能在新选项卡中向用户显示 Excel 文件
现实:
- Excel 文件已下载
最佳答案
“在浏览器中打开 Office 文件”此功能适用于受以下限制的公共(public)可访问的 Office 文档。您可以引用this article并检查您的 Excel 文件是否符合要求:
The OpenInOfficeViewerIfApplicable feature watches navigations to detect when Office-related file extensions (
.xls, .docx, pptx
, etc) orContent-Types
(application/msword, application/vnd.ms-excel
, etc) are observed, indicating that a navigation led directly to an Office document that would otherwise be deemed as having a non-webby MIME type and thus normally be converted into a download.The feature is bypassed if:
- The
Open Office files in the browser
checkbox is turned off inedge://settings
- The response contains a
Content-Disposition:attachment
header- The request contains an
Authorization
orProxy-Authorization
header- The user initiated the download from the
“Save As”
item on the browser’s context menu- The referring URL is on a limited set of exempted domains (Office, SharePoint, OneDrive, Blackboard, etc)
- The request method is not
GET
- The file size is not known (e.g.
Transfer-Encoding: chunked
)- The file size is over 100mb
- The browser is running in Incognito mode
- The file was served from an IP address that is not publicly routable
关于asp.net - 有没有办法强制 MS Edge 在自身内部打开 Excel 文件而不是下载它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77273048/