Advertisement

05.20.2008 at 10:05AM PDT, ID: 23418005
[x]
Attachment Details

Request object doesn't return correct UrlEncoded QueryString when it has a percent % sign in it

Asked by dtburdick in Programming for ASP.NET, C# Programming Language, .Net Editors & IDEs

Tags: C# .NET

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.EncryptQueryString(dk.Values["quad_id"].ToString(), "xxxx");


After this line of code, NavigateUrl is set to "quad_print.aspx?qid=QLkXnz5%2bVLY%3d"


This is the EncryptQueryString routine:


public string EncryptQueryString(string stringToEncrypt, string SEncryptionKey)
{
    try
    {
        return HttpUtility.UrlEncode(Encrypt(stringToEncrypt, 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%2bVLY%3d"


However, it gets mangled in quad_stream.aspx.cs file when it hits this line of code:

Quad.quad_id = Convert.ToInt32(Encryption64.DecryptQueryString(Request.QueryString["qid"].ToString(), "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
 
 
[+][-]05.20.2008 at 10:13AM PDT, ID: 21608197

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 10:30AM PDT, ID: 21608338

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 10:30AM PDT, ID: 21608339

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 10:38AM PDT, ID: 21608410

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 11:58AM PDT, ID: 21609135

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 12:10PM PDT, ID: 21609269

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 12:29PM PDT, ID: 21609497

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 12:36PM PDT, ID: 21609588

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 12:41PM PDT, ID: 21609629

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.20.2008 at 01:42PM PDT, ID: 21610163

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, C# Programming Language, .Net Editors & IDEs
Tags: C# .NET
Sign Up Now!
Solution Provided By: Bane83
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.21.2008 at 08:12AM PDT, ID: 21615890

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628