bmzarzaur
bmzarzaur

Reputation: 9

Opening a document in MS Word that is stored on the server

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.

Upvotes: 0

Views: 469

Answers (1)

Bertvan
Bertvan

Reputation: 5033

Setting the MIME type correctly will improve that experience in some browser versions, but it's not really a consistent solution, because eg. Chrome will still ask to save the file. Setting the MIME type can e done by setting Response.ContentType.

If your application runs in a local network, and the file is available over shared folders, you can use file:// url. In that case, you can get closer to your answer, asking for a Html Helper. You can write your own Display Template, for a custom type (eg. NetworkFile).

As for how Sharepoint fixes this, I'm not sure. Maybe there's some Office tooling you can hook into, but that's just a wild guess.

Available MIME types for Office 2007

Response.ContentType on MSDN

Upvotes: 1

Related Questions