I have mvc project. On controller I format link next way:
user.ShortBiography = user.LongBiography.Substring(0, 100) + "... <a href=\"#\">Read more</a>";
On Views the HTML format next way:
<p>@Html.DisplayFor(score => item.ShortBiography)</p>
When I open site on browser, I see this result:
Some text ... <a href="#">Read more</a>
So.MVC doesn't format link. I see only text with tags. So. How it's fix?
You will need to either make ShortBiography a HtmlString or you will need to do this:
@Html.Raw(item.ShortBiography)
I have also used helpers which convert string to HtmlString
@Html.DisplayFor(score => item.ShortBiography.ToHtmlString())
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.