I’m trying to write some text to a website using the System.Web.HttpUtility.HtmlEncode function in C#. The string parameter that I give to the function has some Environment.Newline’s in it, but they are not written out on the website. Does anyone know why this is and how I can fix it. Thanks in advance.
I’m trying to write some text to a website using the System.Web.HttpUtility.HtmlEncode function in
Share
Newline is written out as a physical line break so you will have to either wrap in a pre:
Or replace the new line with a BR AFTER you have HtmlEncoded (or it’ll encode the BR as well):