An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
June 14, 2021 11:23 am GMT
Original Link: https://dev.to/santhosjery/httputility-encode-vs-webutility-encode-34e7
HttpUtility encode vs WebUtility encode
Hello guys, Today I have learned a difference between HttpUtility.HtmlEncode and WebUtility.HtmlEncode. If you use dot net version less than 4.7 then HttpUtility.HtmlEncode encodes the regional languages. If you want to only html tags need to encode then use WebUtility.HtmlEncode.
var regionalText = ""; var htmlText = "<script>alert('OK')"; var httpUtilityRegionalText = HttpUtility.HtmlEncode(regionalText); //தமிழ் var httpUtilityHtmlText = HttpUtility.HtmlEncode(htmlText); //<script>alert('OK') regionalText = ""; htmlText = "<script>alert('OK')"; var webUtilityRegionalText = WebUtility.HtmlEncode(regionalText); // var webUtilityHtmlText = WebUtility.HtmlEncode(htmlText); //<script>alert('OK')
Original Link: https://dev.to/santhosjery/httputility-encode-vs-webutility-encode-34e7
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To