我喜欢确保文件夹中所有的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地址授权。我喜欢这个想法,因为它不需要代码,只需要配置。
发布于 2014-04-22 20:31:47
您不能仅在网站web.config中执行此操作。
如果您可以使用IIS管理器:打开IIS管理器,找到站点,单击要保护的文件夹,然后单击IP地址和域限制。
另外,在右侧操作面板中单击“编辑功能设置”,为未指定的客户端指定操作(例如,使用禁止的方式拒绝,或使用未找到的方式简单地拒绝)。
这将为您生成正确的配置。
发布于 2014-04-22 20:29:55
在根web.config中使用location element:-
<location path="Secure">
<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>
</location>https://stackoverflow.com/questions/23204788
复制相似问题