在特定书签上打开Word文档

时间:2016-02-23 09:30:31

标签: asp.net-mvc razor ms-word

使用MVC 5 Razor视图。 我目前有一个链接,可以在我的about视图中打开一个位于服务器上的文档,如下所示........

<a href="@Url.Content("~/content/docs/My Doc - Basic Training.docx")">Basic Training <img src="~/Content/Images/Word.jpg" height="24" width="24" /></a>

我想要的是能够在特定书签上打开此文档的链接。

从我到目前为止所读到的内容来看,书签似乎是在#符号之后指定的。不幸的是,它似乎不起作用,文档从一开始就打开了。

我尝试使用#&#39;作为记录的符号,但至今,没有快乐。

FileStream fs = new FileStream(Server.MapPath(@"~\Content\My Doc - Basic Training.docx"), FileMode.OpenOrCreate, FileAccess.ReadWrite);
return File(fs, "My Doc - Basic Training.docx");

我只是将#BoomarkName附加到文件名中。到目前为止还没有快乐。

有可能吗? 如果是这样,请有人指出我正确的方向。

1 个答案:

答案 0 :(得分:0)

似乎与#bookmark_name合作,如How to create a hyperlink from an HTML page to a bookmark in Word中所述。

所以:

<a href="@Url.Content("~/content/docs/My Doc - Basic Training.docx#your_bookmark")">Basic Training <img src="~/Content/Images/Word.jpg" height="24" width="24" /></a>
相关问题