.net core 使用AntiXSSLibrary,HtmlSanitizationLibrary 防止xss攻击
电脑版发表于:2020/1/3 11:39
先下载相关依赖:
install-package AntiXSSLibrary
install-package HtmlSanitizationLibrary
下载成功后一个方法即可
Sanitizer.GetSafeHtmlFragment(dae.Content); (这个方法是HtmlSanitizationLibrary 库里边的,应该是用其中一个即可)
.netframework中也类似,下载一个库调用一下里边的方法即可
注入可能会报错:Sanitizer.GetSafeHtmlFragment报错Could not load file or assembly 'System.Configuration.ConfigurationManager
参考:http://www.tnblog.net/aojiancc2/article/details/3355