views:

404

answers:

2

Hi. 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 ?

+2  A: 

Edit: in response to commment, now including parameters:

<% =Html.BuildUrlFromExpression<YourController>(c => c.YourAction(parameter)) %>
Casper
Could you please provide a sample of how to use the BuildUrlFromExpression(...) Method?I can't get the parameters right. maybe I'm missing something
Tigraine
Wondering how you could add a parameter that's not required by the Controller Action (eg. I'm using a URL like: Article/<id>/<otherId>/<articleName> .. The ArticleName is just for SEO and has no meaning to my Controller. So I just ignore it. With the BuildUrlFromExpression stuff I can't include it..
Tigraine
+8  A: 

MVC also provides a UrlHelper class which can do the same thing:

<%=Url.Action(actionName)%>
<%=Url.Action(actionName, htmlValues)%>
<%=Url.Action(actionName, controllerName, htmlValues)%>
Dave Weaver
Awesome, this is what I've been searching for! Thanks
Tigraine