当web.config包含ipSecurity权限时,允许"localhost"在iisexpress中运行

car*_*ac7 12 web-config localhost iis-express visual-studio-2013

我刚把它添加到我的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>
Run Code Online (Sandbox Code Playgroud)

完全按预期工作,仅在某个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".
Run Code Online (Sandbox Code Playgroud)

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

Abe*_*uez 15

我刚遇到同样的情况.我搜索了一下,发现你所要做的就是编辑IIS Express 的applicationhost.config文件:

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

打开它并查找system.webServer部分中的ipSecurity部分,并将overrideModeDefault从"Deny" 更改为"Allow".您无需从Windows功能添加IIS IP安全性.

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

希望这可以帮助!

  • 请参阅此答案 - http://stackoverflow.com/a/33710459/261690 - 在VS2015下,applicationhost.config现在位于项目特定位置. (8认同)
  • 必须有更多的东西.我已经在两台不同的PC上尝试过这种方法 - 但它不起作用.我仍然收到相同的错误消息"此配置部分不能在此路径中使用.这种情况发生在......"两者上. (4认同)
  • 403.502和503代码与IIS中的IP限制模块相关.我相信你可能会阻止自己.(http://forums.iis.net/p/1210696/2075884.aspx?Re+IIS+8+IP+Restrictions+HTTP+403+503+Code)编辑:哦等等!您必须将localhost添加到允许列表中.<add allowed ="true"ipAddress ="127.0.0.1"subnetMask ="255.255.255.255"/> (2认同)

归档时间:

查看次数:

5001 次

最近记录:

6 年,3 月 前