Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Cannot render raw html in a Razor component

$
0
0

I have a following Razor component (Blazor serverside?) in ASP.NET Core 3.0 Razor pages (normal) project:

@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 HtmlString(n.Text), Link = n.RssLink };                return q.ToList();            }        }    }    public class QNewsList    {        public string Datum;        public HtmlString Text;        public string Link;    }}

The component is rendered in a normal cshtml razor page:

@(await Html.RenderComponentAsync<WEKA.Components.NewsList>(RenderMode.Static))

I am trying to make the database field Text appear on the web page as raw HTML (i.e. rendering &nbsp; as a space). The Html object is not available here to call Html.Raw.

This code above does not render raw html from database. How can I fix it?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>