Salman Lone
Salman Lone

Reputation: 1596

Using .net core, how can i show the html content coming from database on view

I have the business login written in Application_BeginRequest method of Global.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.

Upvotes: 11

Views: 26344

Answers (1)

Salman Lone
Salman Lone

Reputation: 1596

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.

Upvotes: 24

Related Questions