改变查询字符串的值
我在查询字符串中收到错误。我的项目是由 ms Visual Studio 2003 编写的。请参阅下面的代码
<a target="_blank" href="./PageOne.aspx?Customer=NAME1 + NAME2 + NAME3 PARA TEST">NAME1 + NAME2 + NAME3 PARA TEST</a>
系统尝试在 PageOne 上获取客户值,如下所示
Request.QueryString("Customer").ToString
值是
NAME1 NAME2 NAME3 PARA TEST
加号 被空格替换。请分享我如何解决这个问题。
I got the error in Query String. My project was written by ms visual studio 2003. Please see my code below
<a target="_blank" href="./PageOne.aspx?Customer=NAME1 + NAME2 + NAME3 PARA TEST">NAME1 + NAME2 + NAME3 PARA TEST</a>
System tried to get the customer value at PageOne like below
Request.QueryString("Customer").ToString
The value is
NAME1 NAME2 NAME3 PARA TEST
The plus sign is replaced by space. Please share me how to fix this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
URL 受URL 编码和解码的约束。不幸的是,对于您的 URL,在此编码方案中,
+
代表文字空格。您可以通过自己对 URL 进行编码来解决此问题,以便浏览器知道您的参数中有应保留的文字+
符号,例如:URL's are subject to URL encoding and decoding. And unfortunately for your URL, in this encoding scheme a
+
represents a literal space. You can fix this issue by encoding the URL yourself so that the browser knows that you have literal+
signs in your parameter that should be preserved, like:尝试在 URL 中进行 Url 解码 - 更多信息请参见 - HttpServerUtility.UrlDecode 方法(字符串)< /a>
Try Url decoding in the URL - More info here - HttpServerUtility.UrlDecode Method (String)