ASP.NET MVC HtmlHelper.ActionLink replace% 20 with +

If I have a url generated this way

<%=Html.ActionLink("Link name", "MyAction", "MyController", new { SomeParameter = "value with spaces" })%>

can easily generate html output this way

<a href="/MyController/MyAction/value+with+spaces">

instead

<a href="/MyController/MyAction/value%20with%20spaces">

Or is it best for me to look at overloading the ActionLink method and replacing these characters when returning a string?

+3
source share
1 answer

Or am I best looking at overloading the ActionLink method and replacing these characters when returning a string?

Yes.

A simpler way is to simply create a space-dash extension method. Or just call "Replace manually."

<%=Html.ActionLink("Link name", "MyAction", "MyController", new { SomeParameter = "value with spaces".Replace(" ", "-" })%>
+4
source

Source: https://habr.com/ru/post/1730325/


All Articles