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

标签 web-config localhost visual-studio-2013 iis-express

我刚刚将其添加到我的 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 范围内按预期工作。但是,现在当我通过 localhost 通过 iisExpress 在 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".

我已经在服务面板中的本地计算机上设置了 IPSecurity,以便启用它,并且我已经在 ipSecurity block 中使用了选项,例如添加“localhost”作为域名值 - 但可惜没有运气。 ....帮助我 StackOverflow,你是我唯一的希望! ;)

最佳答案

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

%userprofile%\Documents\IISExpress\config\applicationhost.config

打开它并查找 system.webServer 部分中的 ipSecurity 部分,并将 overrideModeDefault 从“拒绝”更改为“允许”。您无需从 Windows 功能添加 IIS IP 安全性

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

希望这有帮助!

注意:对于 Windows 10Visual Studio 2015(或更高版本),请注意 ApplicationHost.config 文件已重新定位到 .vs\项目文件夹层次结构中的 config 文件夹

关于web-config - 当 web.config 包含 ipSecurity 权限时允许 "localhost"在 iisexpress 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22508700/

相关文章:

c# - 如何使用 ConfigurationManager 打开配置文件应用程序设置?

iis - 间歇性 IIS/Azure 错误

c# - web.config 批处理 ="false"

Hadoop : Permission denied (publickey, 密码,键盘交互)

PHPMyAdmin 在外键设置上抛出错误

web - 使用 Web Essentials 2013 生成 typescript 智能感知文件不起作用

tfs - 在 TFS 2013 上构建失败,但在本地正常

caching - IIS7 Web.Config 缓存 - 这里有什么区别,它们是如何结合在一起的?

php - 我无法将 drupal 迁移到本地服务器

.net - Visual Studio 发布选择错误的 web.config 转换