Now for this article first we will create a new asp.net core 8 mvc application with C#.Net. Now add a model class file as shown below.
namespace Project.Models
{
    public class UserModel
    {
        public string ProfileComment { get; set; }
    }
}
        [HttpGet]
        public IActionResult Index()
        {
            UserModel userModel = new UserModel();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < 5; i++)
            {
                sb.Append("<div><b>Comment " + i + "</b>: This is a test <i>comment</i>.<br/></div>");
            }
            userModel.ProfileComment = sb.ToString();
            return View(userModel);
        }
@model UserModel
@{
    ViewData["Title"] = "Home Page";
}
<h2>HTML Content Display</h2>
<br />
<div>@Model.ProfileComment</div>
Here we are having all html content prepared at controller end. Now press F5 to check the final output.
@model UserModel
@{
    ViewData["Title"] = "Home Page";
}
<h2>HTML Content Display</h2>
<br />
<div>@Html.Raw(Model.ProfileComment)</div>



