ASP.NET MVC URL decode

Bryan picture Bryan · Apr 9, 2010 · Viewed 13.8k times · Source

I have an action like this:

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

This produces the following link: http://localhost:1855/Home/About/%C3%96sterreich

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

I have tried.

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

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

Answer

Marek picture Marek · Apr 9, 2010

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

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

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

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.

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

This is only a cosmetic issue.