Show new lines from text area in ASP.NET MVC
Try (not tested myself):
comment = comment.Replace(System.Environment.NewLine, "<br />");
UPDATED:
Just tested the code - it works on my machine
UPDATED:
Another solution:
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringReader sr = new System.IO.StringReader(originalString);
string tmpS = null;
do {
tmpS = sr.ReadLine();
if (tmpS != null) {
sb.Append(tmpS);
sb.Append("<br />");
}
} while (tmpS != null);
var convertedString = sb.ToString();
to view html tags like a DisplayFor
you need to use another method , in fact the mvc dosent allowed you to view tags in page
but you can used this to ignore this option
@Html.Raw(model => model.text)
good luck