【问题标题】:localhost works eventhough mapping in hosts is commented [closed]即使主机中的映射被评论,本地主机仍然有效[关闭]
【发布时间】:2013-05-23 03:09:41
【问题描述】:

当主机文件中到 127.0.0.1 的映射被注释掉时,为什么 localhost 在 Windows 7 Pro 上对我有效?例如,当我在 Visual Studio 中发布网站时,我可以在导航到该网站时使用 localhost。

主机

# 127.0.0.1   localhost

【问题讨论】:

  • localhost 应该只工作,如果它在主机文件中注释,而 Visual Studios 是打开和运行。如果设置了主机文件,它将始终有效

标签: c# asp.net windows iis


【解决方案1】:

有效的 Windows 7,DNS 现在自动处理 localhost 的解析,而不是 hosts 文件。

编辑:这里有一个来源,如果你需要的话,https://superuser.com/questions/453359/do-did-all-versions-of-windows-ship-with-a-host-file-and-do-they-all-have-a-lo/453360#453360

【讨论】:

    【解决方案2】:

    答案在 hosts 文件中(虽然可能不是你的)。从我的 Windows 7 主机文件中:

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

    【讨论】:

      猜你喜欢
      • 2014-03-09
      • 2011-03-09
      • 2021-08-21
      • 2015-05-10
      • 2023-03-14
      • 2012-06-05
      • 2020-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多