Add mailto link to actionlink

How to add mailto link in MVC Html.Actionlink Helper?

@foreach (var item in Model) {
    <tr>
        <td>
            @{ var email = "mailto:" + item.user.Firstname + "@testmail.org";}
            @Html.ActionLink(item.user.Fullname, email)

        </td>

      

only creates a link in the browser: http: // localhost: 53371 / Open / mailto% 3amail% 40testmail.org

+3


source to share


2 answers


You don't want to use it Html.ActionLink

here as you are not specifying a route for it, like a controller or an action.

Try this instead:



@{ var email = "mailto:" + item.user.Firstname + "@testmail.org";}
<a href="@email">@item.user.Firstname</a>

      

+6


source


You can not.



Do you really need to use @ Html.ActionLink? Just use the standard html anchor tag

+1


source







All Articles