web.config - 重写规则以更改标头值不起作用

问题描述 投票:0回答:1
asp.net-core iis web-config url-rewrite-module
1个回答
0
投票

以下设置适合我。

<?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>
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.