如何通过http发送加号(+)符号?

时间:2014-09-04 09:40:40

标签: c# html asp.net

我想知道如何通过http链接发送加号(+),因为当我尝试在编码后发送它像这样的%2B仍然是我得到空的空间。如果我尝试使用+,我会得到双倍空的空间。请帮助我。

我使用浏览器将这样的内容发送到页面:

   localhost:/CPA-API/MT.aspx?msg=Testing%2BTesting

并从后面的代码接收:

   msg = Server.UrlDecode(Request.QueryString["msg"].ToString());

但我得到这样的输出:

   msg = Testing Testing

提前致谢。

1 个答案:

答案 0 :(得分:1)

尝试不使用urldecode

string msg = Request.QueryString["msg"];
string decoded = Server.UrlDecode(msg);

结果:

msg = "Testing+Testing"
decoded = "Testing Testing"