【问题标题】:asp net core 2.* IpRestrictionModuleasp net core 2.* IpRestrictionModule
【发布时间】:2018-01-08 08:40:07
【问题描述】:

asp net core 1.* 以前可以使用IpRestrictionModule,现在不行了……这是我的设置

<system.webServer>
    <!--http://www.henrihietala.fi/limit-access-to-your-azure-web-app-by-ip-address-asp-net-core/-->
    <!--http://www.sasanyeganegi.com/2013/12/how-to-restrict-access-by-ip-in-aspnet.html-->
    <security>

      <!-- this line blocks everybody, except those listed below -->
      <ipSecurity allowUnlisted="true">

        <!-- removes all upstream restrictions -->
        <clear/>

        <!-- allow requests from the local machine -->
        <add ipAddress="127.0.0.1" allowed="true"/>

        <!--allow network 83.116.119.0 to 83.116.119.255-->
        <!--<add ipAddress="83.116.119.0" subnetMask="255.255.255.0" allowed="true"/>-->

        <!-- allow the specific IP of 83.116.19.53  -->
        <add ipAddress="83.116.19.53" allowed="true"/>

        <!--allow network 83.116.0.0 to 83.116.255.255-->
        <!--<add ipAddress="83.116.0.0" subnetMask="255.255.0.0" allowed="true"/>-->

        <!--allow entire /8 network of 83.0.0.0 to 83.255.255.255-->
        <!--<add ipAddress="83.0.0.0" subnetMask="255.0.0.0" allowed="true"/>-->

      </ipSecurity>

    </security>
</system.webServer>

以下是错误:

Detailed Error Information:

Module      IpRestrictionModule
Notification    BeginRequest
Handler     aspNetCore
Error Code  0x80070021
Config Error    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".

Config File \\?\C:\Users\XXXXXXX\repos\YYYY\ZZZZZ\web.config

Config Source:
   13:       <!-- this line blocks everybody, except those listed below -->
   14:       <ipSecurity allowUnlisted="true">
   15: 

asp.net core 2.* 是否改变了IpRestrictionModule 的实现方式?

【问题讨论】:

标签: asp.net asp.net-core .net-core asp.net-core-2.0 asp.net-core-1.0


【解决方案1】:

我的本​​地主机(位于 C:/Windows/System32/drivers/etc/hosts)有

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

所以http://localhost:3023 选择了最后一个 :: ::1 并且它不是 IP 地址,所以 IpRestrictionModule 将永远无法解决它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-30
    • 2018-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-05
    • 2020-08-30
    相关资源
    最近更新 更多