Optimize notifications using the HTML Encode method

Problem

When randomly generated passwords are included in notifications, such as in a welcome email for a new employee, certain special characters may be hidden due to their special meanings in HTML. This can lead to display errors.

Solution

You can reference the C# HTMLEncode method to convert special HTML characters into safe encoded HTML equivalents. This ensures that passwords are displayed correctly without compromising their integrity. 

To use HTMLEncode, change the password expression in your notification from the standard:

{User.Password}

to

{HttpUtility.HtmlEncode(User.password)}

Explanation

Creating password notifications using the HTMLEncode method will ensure that email clients will show the correct password, including any/all special characters. 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.