简体   繁体   中英

ASP Response.Redirect Does Not URLEncode “+” Sign

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 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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