html - 使用 ActionLink 将目录的值从锚标记传递到控制器
问题描述
我正在尝试使用 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() 然后打开文件或目录
解决方案
如果我理解正确,您正在尝试将 item.folder 的内容发送到控制器中的操作?
如果是这样,请考虑制作一个带有 item.folder 文本字段的表单。表单方法可以是 Get 而不是 Post。
推荐阅读
- ios - MPSCNNConvolution 在施工中崩溃
- c++ - 推回功能的容量问题
- user-interface - 是否可以在没有对象大小的情况下计算每度视角的点数?
- reactjs - 使用 ReactRouter nas PHP 托管进行反应
- performance - Spring JPA 在 postgres 数据库中插入数据需要太多时间和内存
- python - 使用用户的输入在 excel 文件中搜索特定行(python)
- javascript - React Native中VirtualzedList更新慢时返回的对象含义
- php - 以逗号分隔的字符串拆分并在 MySQL 和 PHP 中显示
- python - 具有多个迭代器的 Python 多处理部分池
- python - 限制 Windows 中的 python 脚本 RAM 使用