开发者

How to avoid default URL encoding in ASP.NET MVC Html Helpers like RouteLink

开发者 https://www.devze.com 2023-01-22 04:31 出处:网络
I want my url like this: \"http://domain.com/tag/高兴\" My route mapping: routes.MapRoute(\"Tag\", \"tag/{name}\", new { controller = \"Tag\", action=\"Index\" });

I want my url like this:

"http://domain.com/tag/高兴"

My route mapping:

routes.MapRoute("Tag", "tag/{name}", new { controller = "Tag", action="Index" });
开发者_运维问答

But Html.RouteLink will encode the parameters as default. If I use Html.RouteLink in my View, the generated html is:

<a href="/tag/%E9%AB%98%E5%85%B4">高兴</a>

Is there any way to avoid this?


Changed my example.

This works in my case

<%= HttpUtility.UrlDecode(Html.RouteLink("Test", new { id = "高兴" }).ToString())%>

Make sure to change from <%: to <%=

0

精彩评论

暂无评论...
验证码 换一张
取 消