I would like to render a list of HTML links in ASP.NET MVC. Note that the links are absolute and external to the website being designed. The following code
You are not missing anything but good approach is to create extender method on HtmlHelper:
public static class HtmlHelpers
{
public static string SimpleLink(this HtmlHelper html, string url, string text)
{
return String.Format("{1}", url, text);
}
}
then you can use it like this:
<%= Html.Encode(item.Id) %>
<%= Html.SimpleLink(item.Url,item.Text) %>
[edit] I forgot to add. In order to use this HtmlHelper extender throughout application you need to add the following in the web config file: