The Request object is unable to get a correct QueryString value when it has a percent sign %. The value has been URL encoded, so I'm not sure how to handle it.
The following code works fine when there is no % sign in the URL, but dies when there is.
hl_quad_print.NavigateUrl = "quad_print.aspx?qid=" + Encryption64.EncryptQueryS
tring(dk.V
alues["qua
d_id"].ToS
tring(), "xxxx");
After this line of code, NavigateUrl is set to "quad_print.aspx?qid=QLkXn
z5%2bVLY%3
d"
This is the EncryptQueryString routine:
public string EncryptQueryString(string stringToEncrypt, string SEncryptionKey)
{
try
{
return HttpUtility.UrlEncode(Encr
ypt(string
ToEncrypt,
SEncryptionKey));
}
catch (Exception e)
{
return e.Message;
}
}
Inside of quad_print.aspx is the following:
<img alt="Quad Chart Image" src="quad_stream.aspx?qid=
<%= Request.QueryString["qid"]
.ToString(
) %>" />
When I view the resulting page source the value is set appropriately as follows: href="quad_print.aspx?qid=
QLkXnz5%2b
VLY%3d"
However, it gets mangled in quad_stream.aspx.cs file when it hits this line of code:
Quad.quad_id = Convert.ToInt32(Encryption
64.Decrypt
QueryStrin
g(Request.
QueryStrin
g["qid"].T
oString(),
"xxxx"));
When I do a QuickWatch on Request.QueryString["qid"]
.ToString(
) The value it shows is "QLkXnz5 VLY=". Clearly the % signs are causing a problem.
Here are the values next to each other for reference:
"QLkXnz5%2bVLY%3d"
"QLkXnz5 VLY="
What gives? The value is being UrlEncoded.
Start Free Trial