html - 如何在类文件中包含 HtmlSanitazationLibrary
问题描述
我已经安装了还安装了 HtmlSanitizationLibrary 的 AntiXssLibrary nuget 包。我可以包含 AntiXssLibrary
`using System.Web.Security.AntiXss;`
然后在我的代码中使用它:
`AntiXssEncoder.HtmlEncode(value, true);`
我尝试对 HtmlSanitizationLibrary 执行相同操作,但 Visual Studio 2019 无法识别类似的 using 语句。如何实现/使用 HtmlSanitizationLibrary?
解决方案
HtmlSanitizationLibrary 隐藏在一个完全不同的命名空间中,即使它与同一个库一起安装。
using Microsoft.Security.Application;
string html_fragment = "some unsafe html containing XSS";
string safe_html = Sanitizer.GetSafeHtmlFragment(html_fragment);
请参阅https://documentation.help/Microsoft-AntiXSS/documentation.pdf,第 162 - 165 页。
推荐阅读
- c# - PDF泰语字符问题
- javascript - 为什么计时器没有按预期工作?
- angular - 错误未显示在 Angular 的 HTML 端
- excel - 如何在将列表转换为数组然后比较数组时修复错误?
- javascript - 我有什么方法可以在网站上部署 Telegram 机器人吗?
- angular - Angular中测试用例的未定义属性错误
- linux - 如何使用 make & kubernetes 实现 distcc?
- android-studio - 如何从密钥库 Sha1 密钥用于发布模式?适用于 Windows 10 的 Java JDK 11
- php - 拆分数组并在laravel中插入数据库
- python-3.x - 将每列值拆分为不同的列