ASP.NET MVC URL德code [英] ASP.NET MVC URL decode

查看:157
本文介绍了ASP.NET MVC URL德code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的动作:

<%=Html.ActionLink("My_link", "About", "Home", new RouteValueDictionary { 
    { "id", "Österreich" } }, null)%>

这会产生以下链接:<一个href=\"http://localhost:1855/Home/About/%C3%96sterreich\">http://localhost:1855/Home/About/%C3%96sterreich

我想一个链接,看起来像这样 - 本地主机:1855 /首页/ /Österreich

I want a link which looks like this - localhost:1855/Home/About/Österreich

我都试过了。

Server.HtmlDecode("Österreich")
HttpUtility.UrlDecode("Österreich") 

既不似乎帮助。我可以尝试还有什么让我想要的结果?

Neither seems to be helping. What else can I try to get my desired result?

推荐答案

我觉得这是你的浏览器(IE)的问题。

I think this is an issue with your browser (IE).

您code是正确的,因为它是,没有明确的URL编码需要的。

Your code is correct as it is, no explicit UrlEncoding needed.

<%=Html.ActionLink("My_link", "About", "Home", new RouteValueDictionary { 
{ "id", "Österreich" } }, null)%>

有什么错ASP.NET MVC。看到网络上的UNI code的URL,例如的http://他。 wikipedia.org/wiki/%D7%9B%D7%A9%D7%A8%D7%95%D7%AA 在IE和处理的正确网址,UNI code的浏览器。

There is nothing wrong with ASP.NET MVC. See unicode urls on the web, e.g. http://he.wikipedia.org/wiki/%D7%9B%D7%A9%D7%A8%D7%95%D7%AA in IE and in a browser that handles unicode in URLs correctly.

例如。镀铬单显示code网址,没有任何问题。 IE浏览器在地址栏没有去code特殊UNI code字符。

E.g. chrome displays unicode URLs without any problem. IE does not decode "special" unicode characters in address bar.

这只是一个表面问题。

这篇关于ASP.NET MVC URL德code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆