在web.config文件里面配置
<customHeaders>
<add name="X-XSS-Protection" value="1;mode=block"/>
<add name="X-Content-Type-Options" value="nosniff"/>
<add name="Content-Security-Policy" value="default-src 'self';" />
</customHeaders>
前端配置方法
<meta http-equiv="X-XSS-Protection" content="1; mode=block" />
<meta http-equiv="X-Content-Type-Options" content="nosniff" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self'"/>