Search code examples
c#asp.netencodingdecoderequest.querystring

How to solve Url encode and decode issue with some special character and numbers


I have a some url data save in database that data is saved in as a encryption format like this below:

i.e: Wwrjf5OxVEznsWInNFwucg== 

that was okay but sum time encryption will be like this

i.e: Wwrjf5OxV+EznsWInNFwucg==

in that case when i read the Request.QueryString["QueryString"] or Request.Params["Params"]

then i will get the string with the space between encryption if there is a value with "+" between the encryption so how can i solve this issue of "+" in QueryString or Params read.

please let me know a batter solution for solve this issue

thank you


Solution

  • you can use this for url encode and decode.

    string encodedUrl = HttpContext.Current.Server.UrlEncode(Request.QueryString["QueryString"]);
    string decodedUrl = HttpContext.Current.Server.UrlDecode(encodedUrl);