ActionUrl in ASP.NET MVC Preview 5
-
02-07-2019 - |
Question
I don't need a Link but rather only the href= part of the ActionLink.
But if I call Html.ActionLink(...) I get a back. Is there a way to just return the URL of the Action while not getting the ?
Solution
MVC also provides a UrlHelper class which can do the same thing:
<%=Url.Action(actionName)%>
<%=Url.Action(actionName, htmlValues)%>
<%=Url.Action(actionName, controllerName, htmlValues)%>
OTHER TIPS
Edit: in response to commment, now including parameters:
<% =Html.BuildUrlFromExpression<YourController>(c => c.YourAction(parameter)) %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow