Search code examples
asp.netwebformshtml-encode

Microsoft.Security.Application.Encoder.HtmlEncode preventing single quotes from rendering


As a security measure we're using the Microsoft.Security.Application.Encoder.HtmlEncode method to encode and render values that have been stored in our database by various users.

We would like to allow the user to use single quotes but they are being encoded as & #39;

Does anyone know of a safe way to allow single quotes to render but ensure the rest of the input is encoded? Is it just a case of replacing after the encoding has taken place? This approach seems a bit hacky.


Solution

  • I got to the bottom of this. The web control was also encoding the input data and therefore html encoding was taking place twice.