开发者

ASP Response.Redirect Does Not URLEncode "+" Sign

开发者 https://www.devze.com 2023-02-05 21:23 出处:网络
Before IIS 5.0 Response.Redirect was not encoding the string you privide. It was your own responsibility to URLEncode the string.

Before IIS 5.0 Response.Redirect was not encoding the string you privide. It was your own responsibility to URLEncode the string.

On IIS 4.0 we used

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

With IIS 5.0 we started just using

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

So the new Response.Redirect function URLEncodes your string and there is no other option.

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.

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.

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.

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.

Neither

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

or

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

does the same effect as in开发者_如何学C 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.

Any suggestions?


So the new Response.Redirect function URLEncodes your string and there is no other option.

what do you mean there is no other option ?

server.urlencode still exists

0

精彩评论

暂无评论...
验证码 换一张
取 消