Proper html escape on display is preferred. But you can find html sanitization libraries if you google.
How to cleanse a string
Keith Viking
20
Reputation points
Hi I have a message box on a site. They can enter any characters and submit the form. In Asp.Net webforms we could add decode or encode to stop malicious content from being submitted but what would the equivalent be for MVC (.Net 6) so I can clean the string before storing in a database or sending as an email? I have added the attribute [validateantiforgerytoken] to the POST method.
Developer technologies | ASP.NET | ASP.NET Core
4,826 questions
1 answer
Sort by: Most helpful
-
Bruce (SqlWork.com) 77,926 Reputation points Volunteer Moderator
2023-05-03T15:07:48.9033333+00:00