0

i am trying to encrypt my url id from asp.net razor

In my view I have the following @Html.ActionLink:

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

With that I get the link as follows:

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

And the idea is to hide or encrypt the id for "more security", something like this:

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

And then this is decoded in my controller

I appreciate your help in advance.

Yiyi You
  • 16,875
  • 1
  • 10
  • 22

1 Answers1

0

If you want to hide the Id,you can try to use form post:

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

result: enter image description here

In addition,If you want to use encrypt,you can refer to the link.

Yiyi You
  • 16,875
  • 1
  • 10
  • 22