I have a list of strings that i would like to display in cshtml page (Asp.net C#) ,the problem is instead of having html tags in my text i want to display the text formatted on the page when i run the website.
the output is: <p><strong>some </strong><i>data</i></p>
it should be: some data
this is the C# code in cshtml page:
@foreach (var item in Model)
{
<div>@item.content</div>
}
2
Answers
You can replace HTML codes and tags with empty text using regex.
Click here to verify regex
You need to use
Html.Raw()
so it renders asIHtmlString
in HTML instead ofstring
.