Hello,
I'm having some problems in decoding urls on IIS6.
When I click on URL UTF-8 encoded, resulting querystring replace any non english chars with question marks. For example, if you open http://www.qmpeople.com/ you can see a link in the middle of the page http://www.qmpeople.com/tag/%D1%84 containing an UTF-8 char properly encoded . If you click on it, results page shows incorrect querystring "404;http://www.qmpeople.com:80/tag/?" (see upper left corner)
In fact, unicode char has been replaced with a question mark. Why? I'm becoming crazy because I alredy tried a tons of different solutions.
As you can see I use a 404 custom handler to manage all tags and all pages involved use UTF-8

Thank you in advance for your help

Member 164344
Deleted Member

replace the querystring yourself if you wish. When the page gets requested, set the current url to a string. Then replace all the "coded" parts with the real parts!

Please, could you suggest me how can I do that?
Ho can I access current url by server side? I know only QueryStringMethod...
I want avoid to put an onclick() event

Thank you
Rob

Request.ServerVariables("SERVER_NAME") will return your domain name: www.daniweb.com

Request.ServerVariables("PATH_INFO") will return your extra info: "/FolderName/file.asp"

Request.ServerVariables("QUERY_STRING") will return your querystring: "id=23409&id2=9238"

Put it all together:

currentUrl = (Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("PATH_INFO") & "?" & Request.ServerVariables("QUERY_STRING"))

Then do a replace:
currentUrl = Replace(currentUrl, "%20", " ")

Although, you should really avoid any kind of urlencoding period. Avoid file names with spaces, use underscores or hyphens instead.

Thank you for your help but I already know that server variables and they cannot resolve my problem because:
- Request.ServerVariables("SERVER_NAME") is redundant at all
Request.ServerVariables("PATH_INFO") returns the path of my custom 404 erro page non file system
Request.ServerVariables("QUERY_STRING") would be OK but... the problem is that I cannot read it properly because IIS returns "404;http://www.qmpeople.com:80/tag/?" inestead of "404;http://www.qmpeople.com:80/tag/%D1%84 "

Rob

Hello SheSaidImaPregy,
no i'm not. I just use Response.Write and querystring variable

Hello,
each /tag/tagname page is virtual. By clicking on them my simple custom 404 error handler retrieve current url, extract tagname and then build a custom page for the end user.
I used Response.Write(decodeURI(Request.QueryString())) and Response.Write(decodeURIComponent(Request.QueryString())) but... nothing... If I use any UTF-8 encoded char, it replaces them with '?'
I't incredible... IIS6 fully support UTF-8 encoded urls!!?!?!
Any other suggestion?

are you specifying the UTF-8 at the top of every page? It may be reading a wrong type and converting it the way it thinks it must, then it does not come out the way you wish.

are you specifying the UTF-8 at the top of every page? It may be reading a wrong type and converting it the way it thinks it must, then it does not come out the way you wish.

Yes, but.. nothing... it is definitively a IIS bug. Try yourself with two lines of code...
Thank you anyway

Yes, but.. nothing... it is definitively a IIS bug. Try yourself with two lines of code...
Thank you anyway

Did you try the link I posted above?
Basically it describes a similar problem.

I had the question marks in QUERY_STRING, but not in HTTP_URL.. Definitely an IIS bug, but this helped to get around it.

After the question mark all parameters are shown properly but before it ( in a few words the .asp filename ).... nothing to do.
I use javascript instead of vbscript but it should work fine as well.
Nothing... I'm becoming crazy

After the question mark all parameters are shown properly but before it ( in a few words the .asp filename ).... nothing to do.
I use javascript instead of vbscript but it should work fine as well.
Nothing... I'm becoming crazy

Did you make sure you used HTTP_URL instead of QUERY_STRING? For me when I had this problem, it was a crucial point. The QUERY_STRING looked like this when passed to the 404 error:
some.url.com/??????[proper international stuff AFTER ?]

And the HTTP_URL looked like this:
err404.asp?some.url.com/[proper international stuff BEFORE ?]?[proper international stuff AFTER ?]

Function urlDecode(input)
	inp = Replace(input,"/","%2F")
	set conn = Server.CreateObject("MSXML2.ServerXMLHTTP")
	conn.setOption(2) = SXH_SERVER_CERT_IGNORE_ALL_SERVER_ERRORS
	conn.open "GET", "http://www.neoturk.net/urldecode.asp?url=" & inp, False
	conn.send ""
	urlDecode = conn.ResponseText
End Function

To speed this up, just create a table on your db for decoded and encoded urls and read them on global.asa application.on_start section. Later put them on the application object.
Then put a check procedure for that application obj. in above function and IF decoded url not exists on app array, THEN request it one time from remote page (tip: urldecode.asp should be on different server see: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q316451) and insert it to your db and append to application array object, ELSE return the function from the application obj.

This is the best method I have ever found.
If anybody wants further details on application object, database operations etc. contact me via [email]Email Snipped[/email]
By the way, anybody can use neoturk.net/urldecode.asp freely...

Edited 7 Years Ago by __avd: Email Snipped.

You can see above method successfully working at: SNIP

I also used, HeliconTech's ISAPI_Rewrite Lite version
usage is simple: url = Request.ServerVariables("HTTP_X_REWRITE_URL")
this will return the exact url directed to /404.asp

Edited 7 Years Ago by happygeek: link snipped

This article has been dead for over six months. Start a new discussion instead.