I have no idea why is that. Here is my code and it works perfectly when I try it on localhost but when I upload my website my text has no <br />‘s. Why this could happen? And how can I fix this issue with new lines? (white-space: pre-line; is not a solution for me, it is not working on IE6 and it is messing with my styles)
@Html.Raw(Html.Encode(Model.Body)
.Replace(Environment.NewLine, "<br />"))<br />
As BuildStarted mentioned in the comments, the browsers might either send
\r\nor\n, which will break, if you useEnvironment.NewLine– and I don’t think asp.net will fix that up before running your code.I’d suggest you use a regular expression to replace linebreaks instead:
"\\r?\\n"This should match both cases (I don’t expect any browser to actually use ‘\r’ only).