Use of UrlEncode and UrlDecode Method in Asp.net

Thank you for reading this post, don't forget to subscribe!

UrlEncode Method :

HttpUtility.UrlEncode(string)
Ex:
string encodedText= HttpUtility.UrlEncode(txtrefcode.Text.Trim())
string url = “Test.aspx?enc=” + encodedText;
Response.Redirect(url);

UrlDecode Method :

HttpUtility.UrlDecode(Encoded String);
Ex:
string decodeValue = HttpUtility.UrlDecode(Request.QueryString[“enc”]);