Using .net core, how can i show the html content coming from database on view
Got the solution. i was missing the model. I declared the model and then passed that model to the view and then used @Html.Raw(@Model.Property)
at view to render the HTML.
Thanks @adem caglin.
Related videos on Youtube
Salman Lone
By day: I am doing a job as a Senior Software Engineer. By Night: I give time to myself and my family. For Fun: I play football and watch movies. I believe in team work and innovations. I am goal oriented and I love to learn new things.
Updated on June 04, 2022Comments
-
Salman Lone almost 2 years
I have the business login written in
Application_BeginRequest
method ofGlobal.asax
file where i get an html content from database and set the content at view using literal control.Now i am migrating the project into .net core where i want the same thing to do as mentioned above. I have got the html content in the code using
middleware
but now i am trying to show the content on view but unable to do so.Following is my model
@model string <div id="content">@Model</div>
and i am returning
return View(html);
as a string.
My question is, i want to know the steps that how can i show the html content coming from database on view using .net core.
-
adem caglin over 7 yearsYou can use
@Html.Raw(Model)
to render html string.
-
-
ThomasRones almost 5 yearsNot sure about 1.x, but in .NET Core 2.0 you don't need the second @ (It works both ways though)