Reputation: 499
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
Upvotes: 0
Views: 2278
Reputation: 2426
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);
Upvotes: 0
Reputation: 25221
You've sort of already answered this question in your title... You need to URL-encode it before it goes into your QueryString and decode it when it comes back out.
Write:
Request.QueryString["QueryString"] = HttpUtility.UrlEncode(myEncryptedString);
Read:
var encryptedResult = HttpUtility.UrlDecode(Request.QueryString["QueryString"]);
Upvotes: 1