正在从超链接 URL 中删除查询字符串(互操作)
Query string being removed from Hyperlink URL (Interop)
我正在向包含查询字符串的文档添加 hyperlink。
URL 示例:https://www.website.com.au/paynow/ext?rn=555&amt=95.40
我把这个添加到文档中是这样的-
Dim hyperlink As Word.Hyperlink = WordDocument.Hyperlinks.Add(Me.Range, URL, "", "", "Click me to visit the website")
这将打开网站并忽略传入的查询字符串(基本上 运行 https://www.website.com.au
.
如果我直接复制hyperlinklink(打开文档,右击hyperlink和select"copy link"),然后打开浏览器并粘贴它 --> url 正确加载,并使用查询字符串。
我已经通过 fiddler 进行了检查,文档加载项似乎正在使用返回的最终重定向 URL。从阅读来看,这似乎也可能是 Office 产品的一个已知问题?
此外 - 如果我(以编程方式)采用相同的 URL 我将添加到 hyperlink 并将其添加到 Process.Start("URL"),它加载得很好。
[我什至尝试编码 URL - 没有区别]。
有什么想法,开始发疯了吗?
提前致谢。
原因是 Word 的默认行为,它首先检查 URL 是否指向 Word 文档(如果是,则下载并打开文档)。
此行为可以通过 adding the following Registry key 更改(相应地替换 Office 版本):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
Office.0\Common\Internet\ForceShellExecute:DWORD=1
可在此处找到更多信息:
- MS 支持:You are redirected to a logon page or an error page, or you are prompted for authentication information when you click a hyperlink to a SSO Web site in an Office document
- MS 支持:Error message when clicking hyperlink in Office: "Cannot locate the Internet server or proxy server"
- 所以:Why are cookies unrecognized when a link is clicked from an external source (i.e. Excel, Word, etc…)
我正在向包含查询字符串的文档添加 hyperlink。
URL 示例:https://www.website.com.au/paynow/ext?rn=555&amt=95.40
我把这个添加到文档中是这样的-
Dim hyperlink As Word.Hyperlink = WordDocument.Hyperlinks.Add(Me.Range, URL, "", "", "Click me to visit the website")
这将打开网站并忽略传入的查询字符串(基本上 运行 https://www.website.com.au
.
如果我直接复制hyperlinklink(打开文档,右击hyperlink和select"copy link"),然后打开浏览器并粘贴它 --> url 正确加载,并使用查询字符串。
我已经通过 fiddler 进行了检查,文档加载项似乎正在使用返回的最终重定向 URL。从阅读来看,这似乎也可能是 Office 产品的一个已知问题?
此外 - 如果我(以编程方式)采用相同的 URL 我将添加到 hyperlink 并将其添加到 Process.Start("URL"),它加载得很好。
[我什至尝试编码 URL - 没有区别]。
有什么想法,开始发疯了吗?
提前致谢。
原因是 Word 的默认行为,它首先检查 URL 是否指向 Word 文档(如果是,则下载并打开文档)。
此行为可以通过 adding the following Registry key 更改(相应地替换 Office 版本):
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\
Office.0\Common\Internet\ForceShellExecute:DWORD=1
可在此处找到更多信息:
- MS 支持:You are redirected to a logon page or an error page, or you are prompted for authentication information when you click a hyperlink to a SSO Web site in an Office document
- MS 支持:Error message when clicking hyperlink in Office: "Cannot locate the Internet server or proxy server"
- 所以:Why are cookies unrecognized when a link is clicked from an external source (i.e. Excel, Word, etc…)