How to get full query string parameters not UrlDecoded

Posted by developerit on Developer IT See other posts from Developer IT or by developerit
Published on Wed, 17 Mar 2010 23:19:23 +0000 Indexed on 2010/03/17 23:31 UTC
Read the original article Hit count: 16706

Introduction

While developing Developer IT’s website, we came across a problem when the user search keywords containing special character like the plus ‘+’ char. We found it while looking for C++ in our search engine. The request parameter output in ASP.NET was “c “. I found it strange that it removed the ‘++’ and replaced it with a space…

Analysis

After a bit of Googling and Reflection, it turns out that ASP.NET calls UrlDecode on each parameters retreived by the Request(“item”) method. The Request.Params property is affected by this two since it mashes all QueryString, Forms and other collections into a single one.

Workaround

Finally, I solve the puzzle usign the Request.RawUrl property and parsing it with the same RegEx I use in my url re-writter. The RawUrl not affected by anything. As its name say it, it’s raw.

Published on http://www.developerit.com/


© Developer IT or respective owner

Related posts about ASP.NET

Related posts about Developer IT