I want an encoding function that can support u开发者_运维技巧nicode and works in both asp and asp.net. I will create an encoded url in asp but I want to decode this url in asp.net. How do I do that?
I challenge the premise. Building the same function for classic asp and asp.net is a very bad idea, because asp.net already has functions to handle urls correctly:
System.Web.HttpServerUtility.UrlEncode()
System.Web.HttpServerUtility.UrlDecode()
You can't use these functions from your asp classic code, but it would be insane to use anything other than these function in asp.net.
Don't worry about encoding on one side and decoding on the other. Url Encoding is standard. If you encode your function properly from classic asp (ie: use Server.UrlEncode()
), the built-in Url Decoder for ASP.Net will be able to read it.
Now, for completeness, there are actually a few differences for the built in methods between the two platforms. But they work in your favor here: a url encoded by classic asp's built in function will still be decoded correctly by asp.net's built in function.
精彩评论