Search code examples
asp.net-mvcvisual-studio-2008.net-3.5html.actionlink

How to generate just the URL of the Controller method in ASP.NET MVC


So Html.ActionLink("Report", "SendMail", "Misc", new { id = Model.ImageID }, null) will generate a nicely formatted link.

<a href="http://localhost:3224/Misc/SendMail/5">Send Mail</a>

How can I generate just the URL of the link, short of parsing the output of Html.ActionLink?


Solution

  • Does this work for you

    <%= Url.Content("~/Misc/SendMail/" + Model.ImageID) %>
    

    Or try

    <%= Url.Action( "SendMail", "Misc", new { id = Model.ImageID }) %>