I want to decode the query parameters in the URL. I am passing query parameter value as
"somevalue%"
but when i am fetching the value of parameter it is showing like
"somevalue%25"
I want value as "somevalue%" only. Currently I am using Replace , but i want some decode method.
Thanks.
You can use System.Net.WebUtility.UrlDecode
for this:
<trace source="original">
<message>@(context.Request.Url.Query.GetValueOrDefault("parm"))</message>
</trace>
<trace source="converted">
<message>@(System.Net.WebUtility.UrlDecode(context.Request.Url.Query.GetValueOrDefault("parm")))</message>
</trace>
In trace you would see a result like:
trace (0 ms)
{
"message": "Expression was successfully evaluated.",
"expression": "context.Request.Url.Query.GetValueOrDefault(\"parm\")",
"value": "somevalue%25"
}
original (0 ms)
"somevalue%25"
trace (3 ms)
{
"message": "Expression was successfully evaluated.",
"expression": "System.Net.WebUtility.UrlDecode(context.Request.Url.Query.GetValueOrDefault(\"parm\"))",
"value": "somevalue%"
}
converted (0 ms)
"somevalue%"