HttpUtility.UrlDecode将%2b转换为空格,但我需要将其设为'+' [英] HttpUtility.UrlDecode turns %2b into space, but I need it to be '+'

查看:909
本文介绍了HttpUtility.UrlDecode将%2b转换为空格,但我需要将其设为'+'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用HttpUtility.UrlEncode将参数值设置为'+',以便在页面之间传递安全字符串,因此将'+'转换为%2b,但是当我使用Decode方法时,会给我一个空间。为什么?

解决方案

解码%2b 会给你一个 + ,但解码 + 会给你一个空间。



<所以,你的字符串很可能会被解码两次。如果你从 Request.Querystring 集合中读取它,那么它已经被解码了,所以你不应该再次解码它。


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?

解决方案

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.

这篇关于HttpUtility.UrlDecode将%2b转换为空格,但我需要将其设为'+'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆