AngryHacker
AngryHacker

Reputation: 61606

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?

Upvotes: 1

Views: 124

Answers (2)

Dhaval
Dhaval

Reputation: 166

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

should work for you i think

Upvotes: 0

Ray Lu
Ray Lu

Reputation: 26648

Does this work for you

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

Or try

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

Upvotes: 2

Related Questions