Server.URLEncode is making me nuts......

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/68020?pagenum=1
05 November 2025, 10:53

Topic


bobby131313
Server.URLEncode is making me nuts......
28 December 2008, 10:12


I've been googling this for days now, found plenty of people with the same problem but no solutions.
I'm working on a redirection file for my site. One of them is for eBay, the file grabs the query string "eUrl" then encodes it, ads it to the end of another part of the new url then redirects. It works awesome except for ampersands which some eBay urls have.
I've simplified the code so it just displays the output for testing....
Code:

<%
Dim eUrl
eUrl = Server.URLEncode(Request.QueryString("eUrl"))
Response.write (eUrl)
%>

Here's a sample that breaks...
http://www.coincommunity.com/UrlTest.asp?eUrl=http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=330294744298

You'll see that it just stops at the ampersand.
Any ideas?
Thanks!<

 

Replies ...


SiSL
28 December 2008, 10:53


Try removing \= at inc_func_common edit_hrefs function... <
bobby131313
28 December 2008, 11:06


Sorry I should have explained a little better. This has nothing to do with the forum, it's a completely stand alone file.<
SiSL
28 December 2008, 11:25


You should encode it before you send it to your URLtest.asp

Like you get url , http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=330294744298 right?

Then you encodeURL this... and finally put

http://www.coincommunity.com/UrlTest.asp?eUrl=<encoded url>

If this is done by javascript, you can do it with encodeURIComponent(url)

So in other words, you have to do encoding at script who sends this url to your urltest.asp, not in urltest.asp

if you can't do any modifications, you can simply use trick which may be dangerous if you have other variables...
Like

eURL = Right(Request.QueryString,Len(Request.QueryString)-5)

(5 because of total letters of "eURL=")

<
bobby131313
28 December 2008, 11:42


Now I'm confused. I thought the entire purpose of Server.URLEncode was so I wouldn't have to encode it myself, which is exactly what I'm trying to avoid. Am I wrong?<
SiSL
28 December 2008, 11:43


Ofcourse, but you are UrlEncoding at wrong ASP :)

How would ASP handler be certain if "&view=" is in eURL variable or as another variable? <
bobby131313
28 December 2008, 11:56


Ahhhh... OK, I think I get it now.
It's not the encode fuctions fault, that part of eUrl is left off so it's not even there to encode right?<
SiSL
28 December 2008, 11:57


Yup, you have to use encode at whichever page sends url to this asp , not inside this one...


<
bobby131313
28 December 2008, 12:00


Thanks for your help, I learned something today. bigsmile<
SiSL
28 December 2008, 12:11


Anytime :)<
© 2000-2021 Snitz™ Communications