URL with Cyrrilic querystring not working in IE (but working in Firefox)

自古美人都是妖i 提交于 2019-12-08 04:35:49

问题


On our site, I use the category (in Russian) in the querystring.

E.g.: http://www.odinklik.ru/kategoriya.aspx?cat=люди

If you paste this link in IE8, it is translated to cat=???? and it does not work If I paste it in FireFox, it works.

It gets even more weird: the same URL is reachable from the homepage, and if I click the same URL in IE8 from the homepage it works fine (unless I click open in a new tab, that it is back to ????).

I am using ASP.NET 3.5(C#)


回答1:


Did you try to do encoding on first page and decode from Cyrillic to Unicode and back? Little bit a headache but surly will work.




回答2:


You should URL-encode the category name before adding it to the querystring, rather than relying on the browser to do that for you.

The method HttpServerUtility.UrlEncode should be able to handle this encoding for you.

HttpServerUtility.UrlEncode should give you the link http://www.odinklik.ru/kategoriya.aspx?cat=%D0%BB%D1%8E%D0%B4%D0%B8, which should give you the correct result.

(Note that %D0%BB corresponds to л, %D1%8E to ю, %D0%B4 to д and %D0%B8 to и. As the Unicode values for Cyrillic characters are over U+ff, you will require two URL-encoding bytes for each character.)



来源:https://stackoverflow.com/questions/4368032/url-with-cyrrilic-querystring-not-working-in-ie-but-working-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!