My code reads a website field from a database. The field's values are things likewww.google.com, www.bing.com etc without the preceding http:// (orhttps://).
The MVC model returns and displays this field correctly, but I can't get it to prepend http:// and then make the entire thing clickable.
This is the code I have:
@foreach (var item in Model) {
<tr>
<td>
@if (item.PrimarySiteName != null)
{
@Html.Raw(@("http://" + @item.PrimarySite))
}
</td>
</tr>
}
Without the @Html.Raw, the field actually displays correctly, but this code doesn't even run. Maybe I need to use <a href=""> to wrap the prepended string. Depending upon how I mess with the code, sometimes the double slash is interpreted as a comment ( when I use @{ } for example ). How can I get this link to display and be clickable?