Header Ads

ASP.NET MVC: Encrypt/Decrypt URL Parameters

ASP.NET MVC platform itself provides very powerful libraries to process certain task. Passing information using URL parameters is a common practice in web development whether you want to ass an ID information for certain data retrieval or any other information of sort, but, it is highly recommended to  not to pass any sensitive information like password within the URL parameter to avoid any eternal breaches. It is however also recommended to encrypt URL parameters data information even if it is not sensitive to avoid any external intrusions.

Today, I shall be demonstrating encryption and decryption of URL parameters using with ASP.NET MVC web platform.


Following are some prerequisites before you proceed any further in this tutorial:
  1. Knowledge of ASP.NET MVC.
  2. Knowledge of HTML.
  3. Knowledge of JavaScript.
  4. Knowledge of Bootstrap.
  5. Knowledge of Jquery.
  6. Knowledge of C# Programming.
The running working solution source code is being developed in Microsoft Visual Studio 2019 Professional.

Download Now!

Let's begin now.

1) In the first step, create a new ASP.NET MVC web project and name it "MvcUrlParamEncryptDecrypt".

2) To encrypt and decrypt the URL parameter, use below lines of code, know that below lines of code practice secure encryption and decryption mechanism for URL parameters i.e.


// Encrypt URL Parameter.
string encryptInfo = MvcSerializer.Serialize("My Data", SerializationMode.EncryptedAndSigned);


// Decrypt URL Parameter.
string decryptInfo = MvcSerializer.Deserialize(encryptInfo, SerializationMode.EncryptedAndSigned).ToString();


3) The provided solution demonstrated the encryption and decryption of the URL parameters in a form of a quick UI tool. You can execute the example project and demonstrate the feature in detail. 
4) Now, execute the provided solutio

First, ASP.NET MVC application web application is loaded i.e.

Second, provide target URL, URL parameter key, and URL parameter Value. Then click encrypt and you will see encrypted URL parameter value as shown below i.e.

Finally, to decrypt the URL Parameter value that you have just encrypted, simply click the decrypt and decrypted URL parameter will be shown as below i.e.


In this article, you will learn to encrypt and then decrypt the URL parameter value using ASP.NET MVC platform. You will also learn to use the provided example solution visual features to encrypt and decrypt the URL parameter value.

1 comment: