views:

49

answers:

2

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"&gt;Send Mail</a>

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

+2  A: 

Does this work for you

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

Or try

<%= Url.Action( "SendMail", "Misc", new { id = Model.ImageID }) %>
codemeit
This is good, but the app will run on various IIS boxes (some v6 and some v7), so it could potentially be /Misc.aspx/SendMail, in the case of IIS6.
AngryHacker
Url.Action might be your friend.
codemeit
@codemeit. Yep, thank you. This generates /Misc.aspx/SendMail/1, which is perfect. Now I need the stuff that comes before it. Any idea how to get the domain + virtual directory?
AngryHacker
A: 
<%= Url.Content("~"+Url.Action( "SendMail", "Misc", new { id = Model.ImageID })) %>

should work for you i think

Dhaval