I am unsure of the best way to handle this. In my index view I display a message that is contained in TempData["message"]
. This allows me to display certain error or informational messages to the user when coming from another action (for example, if a user tries to enter the Edit action when they don't have access, it kicks them back to the Index with a message of "You are not authorized to edit this data").
Prior to displaying the message, I run Html.Encode(TempData["message"])
. However, I have recently come into the issue where for longer messages I want to be able to separate the lines out via line breaks (<br>
). Unfortunately (and obviously), the <br>
gets encoded by Html.Encode
so it doesn't cause an actual line break.
How do I process line breaks correctly in Html Encoded strings?