【发布时间】:2023-03-05 12:14:01
【问题描述】:
我喜欢保护 ~/Secure/ 文件夹中的所有 aspx 文件,以便特定 IP 地址可以访问该文件夹的 aspx 文件。我在文件夹中添加了以下web.config文件,希望它添加到父web.config:
<configuration>
<system.webServer>
<security>
<ipSecurity allowUnlisted="false">
<clear/>
<add ipAddress="192.168.100.1" />
<add ipAddress="169.254.0.0" subnetMask="255.255.0.0" />
</ipSecurity>
</security>
</system.webServer>
</configuration>
问题是当我尝试访问文件夹中的任何 aspx 页面时出现此错误:
This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false"。
如何实现这个想法?我喜欢只将一个 web.config 文件包含到一个文件夹中,并强制执行 IP 地址授权。我喜欢这个想法,因为它没有代码和配置。
【问题讨论】:
-
在这方面需要任何额外帮助吗?如果我的回答中缺少任何内容,请告诉我。