1

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?

2 Answers 2

2

Does this work for you

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

Or try

<%= Url.Action( "SendMail", "Misc", new { id = Model.ImageID }) %>
Sign up to request clarification or add additional context in comments.

3 Comments

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.
Url.Action might be your friend.
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?
0
<%= Url.Content("~"+Url.Action( "SendMail", "Misc", new { id = Model.ImageID })) %>

should work for you i think

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.