0

I am trying to open a MS word doc (.docx) file from my server. The file is saved from a previous form and the path of that file is saved in the database (SQL Server 2008 R2).

What I have currently set up is a search that returns a list of "filenames" back to the view. Right now it is a @Html.DisplayFor(r=>r.filename).

Is there a way to turn that DisplayFor into a link that opens in some word processor?

I don't want to download the file. I want it to work similar to Sharepoint where you can open the file without having to download a copy.

4

1 回答 1

1

正确设置 MIME 类型将改善某些浏览器版本中的体验,但这并不是一个真正一致的解决方案,因为例如。Chrome 仍会要求保存文件。可以通过设置来设置 MIME 类型Response.ContentType

如果您的应用程序在本地网络中运行,并且文件可通过共享文件夹访问,则可以使用file://url. 在这种情况下,您可以更接近您的答案,要求 Html Helper。NetworkFile您可以为自定义类型(例如)编写自己的显示模板。

至于 Sharepoint 如何解决这个问题,我不确定。也许您可以使用一些 Office 工具,但这只是一个疯狂的猜测。

Office 2007 的可用 MIME 类型

MSDN 上的 Response.ContentType

于 2012-04-29T21:06:19.550 回答