获取包含空格的Query String值

时间:2013-06-03 10:28:37

标签: html asp.net

我的查询字符串的网址是:

http://testpage.aspx?PHONENUMBER=9991234567&CALLBACK_REASON=1st Attempt - First Contact for FNOL

我正在尝试将值设为:

PHONENUMBER= (this.Request["PHONENUMBER"] == null) ? "-" : this.Request["PHONENUMBER"];

CALLBACK_REASON = (this.Request["CALLBACK_REASON"] == null) ? string.Empty : this.Request["CALLBACK_REASON"];

这里我无法获得CALLBACK_REASON值。任何帮助都是grt。

2 个答案:

答案 0 :(得分:1)

Encode您在URI中输入的值。

答案 1 :(得分:0)

您需要使用the spaces encoded生成一个网址(它必须如下所示):

http://testpage.aspx?PHONENUMBER=9991234567&CALLBACK_REASON=1st%20Attempt%20-%20First%20Contact%20for%20FNOL

然后回读这些值,只需使用此代码......

PHONENUMBER= (String.IsNullOrEmpty(this.Request["PHONENUMBER"]) ? "-" : Server.UrlDecode(this.Request["PHONENUMBER"]);

CALLBACK_REASON = (String.IsNullOrEmpty(this.Request["CALLBACK_REASON"]) ? string.Empty : Server.UrlDecode(this.Request["CALLBACK_REASON"]);