问题 当web.config包含ipSecurity权限时,允许“localhost”在iisexpress中运行


我刚把它添加到我的web.config:

<security>
  <ipSecurity allowUnlisted="false">
    <!-- The following IP addresses are granted access, all else denied -->
    <add allowed="true" ipAddress="123.123.105.0" subnetMask="255.255.255.0" />
    <add allowed="true" ipAddress="123.123.100.0" subnetMask="255.255.255.0" />
  </ipSecurity>
</security>

完全按预期工作,仅在某个IP范围内工作。但是,现在当我通过iisExpress通过localhost在Visual Studio中测试它时,它当然给了我一些问题。这是我收到的500.19错误:

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".

我在服务面板中的localmachine上设置了IPSecurity,因此启用了,我在ipSecurity块中添加了选项,例如添加'localhost'作为domainName值 - 但是没有运气。 ....帮我StackOverflow,你是我唯一的希望! ;)


7527
2018-03-19 14:16


起源

我也有这个问题,似乎也找不到解决方案 - Xoundboy


答案:


我刚遇到同样的情况。我google了一下,发现你所要做的就是编辑 对ApplicationHost.config IIS Express的文件在这里找到:

%USERPROFILE%\文件\ IISExpress \设置\对ApplicationHost.config

打开它,寻找 IPSECURITY 里面的部分 system.webServer 部分和变化 overrideModeDefault 从“拒绝”到“允许”。您不需要添加IIS IP安全 来自Windows功能。

<sectionGroup name="system.webServer">
  ...
  <section name="ipSecurity" overrideModeDefault="Allow" />
  ...
</sectionGroup>

希望这可以帮助!


15
2018-05-10 05:59



这样做了,它似乎让我更近了 - 现在我收到以下错误:HTTP错误403.503 - 禁止您没有权限查看此目录或页面。 - cardiac7
403.502和503代码与IIS中的IP限制模块相关。我相信你可能会阻止自己。 (forums.iis.net/p/1210696/...编辑:哦等等!您必须将localhost添加到允许列表中。 <add allowed =“true”ipAddress =“127.0.0.1”subnetMask =“255.255.255.255”/> - AbeyMarquez
必须有更多的东西。我已经在两台不同的PC上尝试过这种方法了 - 但它不起作用。我仍然收到相同的错误消息“此配置部分不能在此路径中使用。这种情况发生在......”两者上。 - Gustin
看到这个答案 - stackoverflow.com/a/33710459/261690  - 在VS2015下,applicationhost.config现在位于项目特定位置。 - Matt Whitfield
在文件中查找此部分:sectionGroup name =“system.webServer” - Rob Sedgwick