UrlHelper.IsLocalUrl方法总是返回"假"非ASCII字符串 [英] UrlHelper.IsLocalUrl method always returns "false" for non-ASCII strings
问题描述
最近,我发现,那 UrlHelper.IsLocalUrl
方法总是返回 假
,如果它检测到 URL非ASCII字符
参数。
I recently detected, that UrlHelper.IsLocalUrl
method always returns false
, if it detects non-ASCII characters in the url
parameter.
例如:
var isLocal = UrlHelper.IsLocalUrl("контакты"); //false
它是一个bug,或设计?
Is it a bug, or "by design"?
推荐答案
最新可用的执行正在检查这些条件:
The latest available implementation is checking for those conditions:
- 的URL以
开始/
,而不是后面/
或\\
- 或URL以
启动〜
,后面跟着/
- the url starts with
"/"
and is not followed by"/"
or"\"
- or the url starts with
"~"
and is followed by"/"
因此,所有传递给此方法的URL必须以/
或〜/
。
Thus all the urls passed to this method must start with "/"
or "~/"
.
此外,如果你想知道,它没有考虑当前主机考虑并检查如 HTTP
方案的实例。
Also, in case you wonder, it doesn't take the current host into account and check for schemes like http
for instance.
更新:
这里是它使用 UrlHelper.IsLocalUrl
实施情况的链接
<一href=\"http://aspnetwebstack.$c$cplex.com/SourceControl/changeset/view/600963a4df15#src%2fSystem.Web.WebPages%2fRequestExtensions.cs\">http://aspnetwebstack.$c$cplex.com/SourceControl/changeset/view/600963a4df15#src%2fSystem.Web.WebPages%2fRequestExtensions.cs
这篇关于UrlHelper.IsLocalUrl方法总是返回&QUOT;假&QUOT;非ASCII字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!