带有 Cyrrilic 查询字符串的 URL 在 IE 中不起作用(但在 Firefox 中起作用)
在我们的网站上,我在查询字符串中使用类别(俄语)。
例如: http:// www.odinklik.ru/kategoriya.aspx?cat=люди
如果您在 IE8 中粘贴此链接,它会被翻译为 cat=????它不起作用 如果我将它粘贴到 FireFox 中,它就可以工作。
更奇怪的是:可以从主页访问相同的 URL,如果我在 IE8 中从主页单击相同的 URL,它可以正常工作(除非我单击在新选项卡中打开,否则它会返回???) 。
我正在使用 ASP.NET 3.5(C#)
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#)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过在第一页上进行编码并从西里尔字母解码为 Unicode 并返回?
有点头疼,但肯定会起作用。
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.
您应该在将类别名称添加到查询字符串之前对其进行 URL 编码,而不是依赖浏览器为您执行此操作。
方法 HttpServerUtility.UrlEncode 应该能够为您处理此编码。
HttpServerUtility.UrlEncode 应该为您提供链接 http://www.odinklik.ru/kategoriya.aspx?cat=%D0%BB%D1%8E%D0%B4%D0%B8,这应该会给你正确的结果。
(注意
%D0%BB
对应于л
,%D1%8E
对应于ю
,% D0%B4
到д
和%D0%B8
到и
因为西里尔字符的 Unicode 值超过。 U+ff
,每个字符需要两个 URL 编码字节。)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 overU+ff
, you will require two URL-encoding bytes for each character.)