I Use MVC and sometimes need to pass the ViewBag.Message from Controller to view, and I need new line, I check this: ViewBag.Message = SomeStrring + "/r/n" + SomeAnotherString; Also this One ViewBag.Message = SomeStrring + "</ br>" + SomeAnotherString; but none of them work, how can I do this?
I Use MVC and sometimes need to pass the ViewBag.Message from Controller to view,
Share
Your slashes are misplaced. It’s
<br/>, and you must output it into the view using@Html.Raw(ViewBag.ErrorMessage)to make it not escape the HTML 🙂