sangram parmar
sangram parmar

Reputation: 8736

get Request.QueryString as it show

VerifyEmail.aspx?key=KMSO+tLs5zY=&val=ALKXZzxNxajUWVMaddKfPG/FcFD111CD

Request.QueryString["key"].ToString() gives me "KMSO tLs5zY="

i want key value "KMSO+tLs5zY="

Upvotes: 2

Views: 325

Answers (2)

Massimo Zerbini
Massimo Zerbini

Reputation: 3191

If you can modify the url parameter, you can encode the values using the HttpUtility.UrlEncode method, for example:

string url = "VerifyEmail.aspx?key=" + HttpUtility.UrlEncode("KMSO+tLs5zY=");

Another method is to use Base64 encoding

string url = "VerifyEmail.aspx?key=" + EncodeTo64("KMSO+tLs5zY=");

and decoding the value reading the querystring

String value = DecodeFrom64(Request["key"]);

the code for the EncodeTo64 and DecodeFrom64 is available in this article http://arcanecode.com/2007/03/21/encoding-strings-to-base64-in-c/

Upvotes: 4

zkanoca
zkanoca

Reputation: 9928

Do not use %2B instead of + when producing url.

And if you get %2B's itself when requesting, do not try to replace it using

Request.QueryString["key"].ToString().Replace("%2B","+")

Use HttpUtility class' UrlEncode() method:

HttpUtility.UrlEncode("KMSO+tLs5zY=")

(:

Upvotes: -2

Related Questions