I have a cshtml that renders a model. One of the property has "\r\n" I want to use as a line break. so what I do is call
@Model.Message.Replace("\r\n", "<br />")
But the razor engine renders as <br /> Any solution?
I have a cshtml that renders a model. One of the property has "\r\n" I want to use as a line break. so what I do is call
@Model.Message.Replace("\r\n", "<br />")
But the razor engine renders as <br /> Any solution?
Just found the following solution:
@(new HtmlString(Model.Message.Replace("\r\n", "<br />")))
It works perfectly!
in ASP.NET MVC Razor view](https://stackoverflow.com/questions/4220381/replace-line-break-characters-with-br-in-asp-net-mvc-razor-view) – Heretic Monkey Oct 11 '18 at 00:18