Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QueryString converted to URL-Encode using NameValueCollection

I am passing an encrypted URL string:

Default.aspx?S3tLlnIKKzE%3d

I want to pass that URL string back into the ASPX page in a variable.

protected string qs = string.Empty;

NameValueCollection qscollstring = HttpContext.Current.Request.QueryString;
qs = qscollstring[0];

Which return : S3tLlnIKKzE=

The value in qscollstring[0] is correct: S3tLlnIKKzE%3d

I understand the problem is URL-Encoding, but I cannot find a way to keep the string as is.

It seems that assigning the value from qscollstring[0] is: S3tLlnIKKzE%3d
to string changes the value : S3tLlnIKKzE=

I need to to stay: S3tLlnIKKzE%3d

like image 952
Ravi Ram Avatar asked Aug 15 '26 20:08

Ravi Ram


1 Answers

Use HttpUtility.UrlEncode method to encode the string.

 qs =HttpUtility.UrlEncode(qscollstring[0]);
like image 131
KV Prajapati Avatar answered Aug 17 '26 08:08

KV Prajapati



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!