是否可以将web.config中的安全性部分添加到外部文件中

Arb*_*æde 2 asp.net asp.net-mvc web.config-transform

我需要通过配置文件阻止一个巨大的IP列表

<security>
      <ipSecurity allowUnlisted="true">
        <clear />          
        <add ipAddress="1.0.1.0" subnetMask="255.255.255.0" />
        <add ipAddress="1.0.2.0" subnetMask="255.255.254.0" />
        <add ipAddress="1.0.8.0" subnetMask="255.255.248.0" />
        <add ipAddress="1.0.32.0" subnetMask="255.255.224.0" />
        ...
      </ipSecurity>
</security>
Run Code Online (Sandbox Code Playgroud)

是否可以将web.config中的安全性部分添加到外部文件中?

fre*_*ide 5

C:\ WINDOWS\SYSTEM32\INETSRV \设置\的applicationHost.config

更改Web服务器的配置:

从:

< section name="ipSecurity" overrideModeDefault="Deny" / > 
Run Code Online (Sandbox Code Playgroud)

至:

< section name="ipSecurity" overrideModeDefault="Allow" / > 
Run Code Online (Sandbox Code Playgroud)

和你的web.config

< configuration > 
< system.webServer > 
< security > 
< ipSecurity configSource="fileWithIps.config" / > 
< /security > 
< /system.webServer > 
< /configuration > 
Run Code Online (Sandbox Code Playgroud)