开发者

Request.QueryString giving me space instead of + sign

If I have a URL value h开发者_如何学Cttp://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?


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.


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


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

Here is list of encodings to use for such characters.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜