【问题标题】:encrypt parameters in @Html.ActionLink加密@Html.ActionLink 中的参数
【发布时间】:2021-01-07 11:11:53
【问题描述】:

我正在尝试从 asp.net razor 加密我的 url id

在我看来,我有以下@Html.ActionLink

@Html.ActionLink(" ","index", "Home", new { id = Server.UrlEncode(item.ID.ToString()) }, new { @class = "fas fa-eye", @title = "Ver Detalle" })

我得到的链接如下:

http://localhost:62201/Home/index/1

这个想法是为了“更安全”而隐藏或加密 id,如下所示:

http://localhost:62201/Home/index/unrecognizable_id

然后在我的controller中解码

提前感谢您的帮助。

【问题讨论】:

    标签: asp.net-mvc asp.net-core encryption razor


    【解决方案1】:

    如果你想隐藏Id,可以尝试使用form post:

    @using (Html.BeginForm("index", "Home", FormMethod.Post))
    {
        <input hidden name="Id" value=@item.ID />
        <input type="submit" value="submit" />
    }
    

    结果:

    另外,如果要使用加密,可以参考link

    【讨论】:

      猜你喜欢
      • 2012-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-18
      • 1970-01-01
      • 2012-10-25
      相关资源
      最近更新 更多