Sometimes its the little bugs that really get to you. They are so small that you spend quite a lot of time figuring out what’s wrong and then it hits you.
In my case, the problem was simple. I had a parameter being passed to me on the URL.
The URL looked something like this:
http://www.myapp.com/somepage.aspx?param1=text1%2c+text2%26text3¶m2=true
param1 has a URL encoded value which translates into (without the double quotes):
“text1, text2&text3“
Yeap, it has a “&” character as the value, but its URL encoded so it suppose to be OK.
When I went to get the value of param1 by using:
var string a = Request.QueryString[“param1”];
The value I got was:
text1, text2
No text3 for some reason.
It seems that in certain cases there is a bug. I suspect that it URL decodes the query string before it cuts it up and fill in the Request.QueryString collection.
I didn’t fill like going through all the massive amounts of code of HttpRequest and friends using Reflector, so I just wrote a function that handles the URL decode and splitting issues correctly.
If you wish, I can post it as a link here.