In one of my programs I have to process an encrypted Url. I want to save the parameter to a string and I want to keep the special characters as they are
string input_url ="domain.com/auth?token=%2FhKjSuSAO6ctIrgokvB9hmHJPlHQXqTmpuH9fEPWp8w";
I want to process the token query string in a decoded form I tried the code
string input_url ="domain.com/auth?token=%2FhKjSuSAO6ctIrgokvB9hmHJPlHQXqTmpuH9fEPWp8w";
val = System.Net.WebUtility.HtmlDecode(input_url.ToString());
val2 = val.Split('=')[1];
But I get the value as %2FhKjSuSAO6ctIrgokvB9hmHJPlHQXqTmpuH9fEPWp8w
What i want is val=/hKjSuSAO6ctIrgokvB9hmHJPlHQXqTmpuH9fEPWp8w
(keep %2F
as /
, like for other special characters if any exists)
How can I do this?
You're using the wrong decoder; this is a URL, not HTML, so try UrlDecode
:
string input_url ="domain.com/auth?token=%2FhKjSuSAO6ctIrgokvB9hmHJPlHQXqTmpuH9fEPWp8w";
val = System.Net.WebUtility.UrlDecode(input_url);
val2 = val.Split('=')[1];
This gives the result in val2
of:
/hKjSuSAO6ctIrgokvB9hmHJPlHQXqTmpuH9fEPWp8w
HTMLDecode
is designed for HTML entites such as &
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With