tags:

views:

28

answers:

4

If I have a URL value http://Localhost/default.aspx?ts=/+m2dAZZA3DaavaaupUXkZL83n7TwmCVm

Request.QueryString[ts] is giving me

/ m2dAZZA3DaavaaupUXkZL83n7TwmCVm

How to ensure that I get all the value from the Querystring

is there an encoding or something?

+2  A: 

Use: http://Localhost/default.aspx?ts=/%2Bm2dAZZA3DaavaaupUXkZL83n7TwmCVm instead.

Special characters in URLs are formatted as %XX where XX is the hex representation of the ASCII value. In this case, the + sign is 43, thus our URL value will be %2B.

Stargazer712
A: 

Do not use a + in the parameter value. Instead, choose another character that is URL friendly and will not otherwise be used. Replace the + before adding the value to the URL. Then replace it with a + when the value is retrieved.

JungleFreak
There is nothing wrong with using special characters in URLs, they simply have to be encoded first.
Stargazer712
Yes, you're right.
JungleFreak
+1  A: 

try using Server.urlencode and Server.urldecode or use %2B instead of +

Here is list of encodings to use for such characters.

Vinay B R
Shouldn't that be `Server.UrlEncode()` or `HttpUtility.UrlEncode()` ?
Dan Diplo
@Dan Diplo - u r right thnx for pointing it out
Vinay B R
+1  A: 

whatever code that generates your URL needs to escape it properly. Use HttpUtility.UrlEncode() server-side or ecodeURIComponent() client-side

liho1eye