以下设置适合我。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\WebApplication1.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
<httpProtocol>
<customHeaders>
</customHeaders>
</httpProtocol>
<rewrite>
<rules>
<rule name="Modify CSP for Viewfile" stopProcessing="true">
<match url=".*viewfile.*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="None" />
<serverVariables>
<set name="RESPONSE_Content-Security-Policy" value="default-src 'none';" />
</serverVariables>
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
</configuration>