-1
@using(Html.BeginForm("Action", "Controller", FormMethod.Get)
{          
  @Html.TextBoxFor(model=>model.Id)
  <input type="submit" value="Search" />
}

1-When we click On Submit Button this will Create Url Like this

    http://localhost:53734/Controller/Action?id=10  
    //10 is input From Textbox

I want to encrypt Id parameter like http://localhost:53734/Controller/Action?id=encrypted Value Of 10

  • 2
    Use HTTPS instead. If you encrypt anything in *Javascript* it will be obvious to whoever has access to the page source. That includes the hackers that may hack any intermediate proxy, router. – Panagiotis Kanavos Mar 26 '19 at 14:31
  • @MohammadAlghanem this is primarily a Javascript question. – Panagiotis Kanavos Mar 26 '19 at 14:33
  • What are you trying to protect against? Prevent someone between client and server from stealing the parameters? Or prevent the server-side code from reading the parameter? Encryption could protect only against the second case – Panagiotis Kanavos Mar 26 '19 at 14:46
  • Only want to protect Url server Side user Can't see the actual value of id Paramete – Pradeep Vaishya Mar 26 '19 at 14:58

1 Answers1

0

As I understand you want to "hide" and "protect" the request. The best solution is to:

  • Use HTTPS so the transport will provide encryption
  • All parameters in GET and POST are encrypted (more Are HTTPS URLs encrypted?).

If it is not possible, use RSACryptProvider to encrypt parameter. The universal encryption code is in MSDN: https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.rsacryptoserviceprovider?view=netframework-4.7.2

Piotr Stapp
  • 19,392
  • 11
  • 68
  • 116