Cannot render raw html in a Razor component
It should work when you use this:
<div class="col name">@((MarkupString)e.Text)</div>
See the doc here and from what @Hrnk has said, you need to use MarkupString
instead of HtmlString
in razor component.Change code to below
@using WEKA.Models
@using Microsoft.AspNetCore.Html
<div class="jobs-list">
@foreach (var e in News)
{
<div class="job" data-aos="fade-up">
<a href="@e.Link">
<div class="col name">@e.Text</div>
<div class="col more">Detail</div>
</a>
</div>
}
</div>
@code {
public List<QNewsList> News
{
set { }
get
{
using (WEKAContext db = new WEKAContext())
{
var q = from n in db.Qaktuality select new QNewsList() { Datum = n.Datum.ToString("d.M.YYYY"), Text = new MarkupString(n.Text), Link = n.RssLink };
return q.ToList();
}
}
}
public class QNewsList
{
public string Datum;
public MarkupString Text;
public string Link;
}
}
Refer to https://github.com/aspnet/Blazor/issues/167
https://github.com/aspnet/AspNetCore/issues/12615