[英]URL Decoder c# asp.net
In a QueryString I have a part that looks like this 在QueryString中,我的一部分看起来像这样
...u4w51EEcg8%2bj04e7C....
When I am using HttpUtility.UrlDecode the part "%2b" which represents a "+" just turns into a white space. 当我使用HttpUtility.UrlDecode时 ,代表“ +”的部分“%2b”变成空白。 I'm using HttpUtility.UrlEncode in the first place to encode the string. 我首先使用HttpUtility.UrlEncode对字符串进行编码。
Does anyone have any clue to what is going on? 有人对发生的事情有任何线索吗?
Are you decoding twice? 您要解码两次吗? For convenience, a +
sign in a URL decodes to 为了方便起见,URL中的+
号会解码为 (space, 0x20). (空格,0x20)。 While
%2b
should decode to +
, decoding that will give you 虽然%2b
应该解码为+
,但解码将为您提供 . 。
EDIT: Just saw your self-answer, and yeah, always check whether your getter functions / properties automatically decode for you. 编辑:刚看到您的自我回答,是的,请始终检查您的getter函数/属性是否自动为您解码。 Double-decoding usually doesn't produce the desired result, and can even lead to security risks. 双重解码通常不会产生预期的结果,甚至可能导致安全隐患。
看起来无论“ Request.QueryString []”如何解码,所以发生的事情是我对QueryString进行了2次解码,这使“ +”成为空白。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.