简体   繁体   English

ASP Response.Redirect不URL编码“ +”号

[英]ASP Response.Redirect Does Not URLEncode “+” Sign

Before IIS 5.0 Response.Redirect was not encoding the string you privide. 在IIS 5.0之前,Response.Redirect未对您私有的字符串进行编码。 It was your own responsibility to URLEncode the string. URLEncode字符串是您自己的责任。

On IIS 4.0 we used 在IIS 4.0上,我们使用了

Response.Redirect Server.URLEncode("Page,One.asp")

With IIS 5.0 we started just using 使用IIS 5.0,我们开始仅使用

Response.Redirect("Page,One.asp")

So the new Response.Redirect function URLEncodes your string and there is no other option. 因此,新的Response.Redirect函数URLEncodes您的字符串,没有其他选择。

There is just one problem. 只有一个问题。 I can not pass a "+" sign in the strings. 我不能在字符串中传递“ +”号。 When Response.Redirect("sum=1+3") is executed, you expect it to encode all the non alphanumeric characters but "+" sign turns into a space character on the receiving page. 当执行Response.Redirect("sum=1+3") ,您希望它对所有非字母数字字符进行编码,但是在接收页面上,“ +”号变成空格字符。

When Response.Redirect(“sum=1%2B3”) is executed, "404 Not Found" is received because "sum%3D1%25B23" does not exist on the server as %2B is encoded twice. 执行Response.Redirect(“sum=1%2B3”) ,由于%2B被编码两次,因此服务器上不存在“ sum%3D1%25B23”,因此收到“ 404 Not Found”。

I want "+" to be encoded as %2B so that the receiving page understands that it is in fact a part of some text and display it. 我希望将“ +”编码为%2B,以便接收页面理解它实际上是某些文本的一部分并显示它。

Let me give you an example: When you type http://translate.google.com/#en|tr|1%2B2 into your browser and pres enter you will see that google accepts %2B and decodes it as a + in the textarea. 让我举一个例子:当您在浏览器中输入http://translate.google.com/#en|tr|1%2B2并按ENTER键时,您将看到google接受%2B并将其解码为+文本区域。

Neither 都没有

Response.Redirect("http://translate.google.com/#en|tr|1%2B2") Response.Redirect(“ http://translate.google.com/#en|tr|1%2B2”)

or 要么

Response.Redirect("http://translate.google.com/#en|tr|1+2") Response.Redirect(“ http://translate.google.com/#en|tr|1+2”)

does the same effect as in the example i gave. 效果与我给出的示例相同。 I just want to redirect to that page. 我只想重定向到该页面。

There is an other way like first encoding the string and then redirecting with Response.Redirect unescape("Page%2COne%2Easp") but escape and unescape functions support some part of UTF-8 and ASCII (0-127) but do not support high ANSI (128-255) characters, notably European accented characters. 还有另一种方式,例如首先编码字符串,然后使用Response.Redirect unescape("Page%2COne%2Easp")重定向Response.Redirect unescape("Page%2COne%2Easp")但是转义和unescape函数支持UTF-8和ASCII(0-127)的某些部分,但不支持高ANSI(128-255)字符,尤其是欧洲带重音符号的字符。

Any suggestions? 有什么建议么?

So the new Response.Redirect function URLEncodes your string and there is no other option. 因此,新的Response.Redirect函数URLEncodes您的字符串,没有其他选择。

what do you mean there is no other option ? 您是什么意思,别无选择?

server.urlencode still exists server.urlencode仍然存在

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM