HttpUtility.UrlDecode turns + into space, but I ne

2019-04-23 17:26发布

I'm using HttpUtility.UrlEncode to turn parameter value which concluds '+' to safe string deliverd among pages, so it turns '+' into %2b, but when I use Decode method it give me back a space. Why?

标签: html http
2条回答
The star\"
2楼-- · 2019-04-23 17:51

Decoding %2b would give you back a +, but decoding a + would give you back a space.

So, most likely your string is decoded twice. If you are reading it from the Request.Querystring collection, then it's already decoded, so you shouldn't decode it again.

查看更多
Explosion°爆炸
3楼-- · 2019-04-23 18:03

Weird, the following prints + on my console (as expected):

Console.WriteLine(HttpUtility.UrlDecode(HttpUtility.UrlEncode("+")));
查看更多
登录 后发表回答