【发布时间】:2020-08-07 11:31:26
【问题描述】:
我正在尝试使用 ActionLink 从锚标记获取目录/文件夹的值到我的控制器。 我已经对值进行了编码,但它总是给我 404 错误。
{item.Folder} 的链接文本/值:\\webserver01\business\application
我得到的价值:%5C%5Cwebserver01%5Cbusiness%5Capplication
原创
@Html.ActionLink(item.Folder, "OpenFolder", new { id = item.Folder }, new { @class = "", @target = "_blank" })
第二个解决方案
@Html.ActionLink(item.Folder, "OpenFolder", new { id = HttpUtility.UrlDecode(item.Folder) }, new { @class = "", @target = "_blank" })
第三种解决方案
@Html.ActionLink(item.Folder, "OpenFolder", new { id = item.Folder.Replace("%5C" "\\" }, new { @class = "", @target = "_blank" })
第四个解决方案 - 将 %5C 替换为 100,然后将 100 替换为 Controller 中的 \\。
@Html.ActionLink(item.Folder, "OpenFolder", new { id = item.Folder.Replace("%5C" "100" }, new { @class = "", @target = "_blank" })
4 个解决方案给我带来了价值:%5C%5Cwebserver01%5Cbusiness%5Capplication
注意事项:
- 我正在尝试在锚标记中打开一个目录。由于“安全问题”,它在 Chrome 中不起作用
- 将使用 Process.Start() 然后打开文件或目录
【问题讨论】:
标签: html asp.net-mvc razor