Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC URL decode

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?

like image 714
Bryan Avatar asked Apr 09 '10 18:04

Bryan


1 Answers

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.

like image 188
Marek Avatar answered Oct 07 '22 07:10

Marek