UrlEn $ C $铜镍code和浏览器导航错误 [英] UrlEncodeUnicode and browser navigation errors
问题描述
我要重定向请求,可能会或可能不包含非ASCII字符(如德语变音)的一些网址。
I want to redirect a request to some URL that may or may not contain non-ascii characters (e.g. german umlauts).
这样做的URL的相关部分:
Doing this with the relevant part of the URL:
var url = HttpUtility.UrlEncodeUnicode("öäü.pdf"); // -> "%u00f6%u00e4%u00fc.pdf"
,然后发出重定向:
and then issuing the redirect:
Response.Redirect(url, ...);
将不会产生预期的行为。它的出现,浏览器(IE,歌剧,据我已经测试)不接受此命令时,URL重定向到是单向code-CN codeD。普通UrlEn code'D路径做工精细。
will not produce the desired behaviour. It appears, the browser (IE, Opera as far as I have tested) doesn't honor this command when the URL to redirect to is Unicode-encoded. Ordinary UrlEncode'd paths work fine.
我已经尝试设置这个在web.config中:
I have tried setting this in the Web.Config:
<configuration>
<system.web>
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
</system.web>
</configuration>
这并没有改变任何事情。
That didn't change a thing.
有什么我可以做的,得到这个工作?
Is there anything I can do, to get this to work?
推荐答案
我不知道有问题,而是你能不能试试这个吗?
I am not sure with question, but could you try with this?
HttpUtility.UrlEncode("öäü.pdf")
或
HttpUtility.UrlEncode("öäü.pdf", Encoding.UTF8)
对不起,如果我理解你的问题走错了路。
Sorry, If I understand your question wrong way.
这篇关于UrlEn $ C $铜镍code和浏览器导航错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!