Reputation: 1758
Is there an Razor method that will allow to put "object to string" inside html like:
<a href="http://@Model.x.y">Anchor</a>
Or do I have to use something like that and change my model?
c# object to string to display it in text format
Thanks
Upvotes: 0
Views: 1369
Reputation: 23927
if the link you are passing from your model is a string the correct syntax would be
<a href="@Html.Raw(@Model.x.y))">Anchor</a>
or
<a [email protected]("http://www." + @Model.x.y))>Anchor</a>
This way you are correctly parsing any special characters which might occur in the link like &
or =
Upvotes: 2