Visual Studio:如何让 Cassini 监听 ::1?
Visual Studio 的内部开发 Web 服务器仅侦听来自本地计算机的连接。
不幸的是,网络服务器仅绑定到 IPv4 环回地址:
127.0.0.1
在启用 IPv6 的计算机上(即 Windows Vista、Window 7),它不会绑定到 IPv6 环回地址:
::1
当您在 Visual Studio 中推送播放或从通知区域图标打开网站时,浏览器会启动并尝试连接到“localhost”:
http://localhost:53289/WebSite/
localhost 不是真实地址,而是一个别名。 在 Vista 及更高版本上,它被定义为:
C:\Windows\System32\drivers\etc\hosts
::1 localhost
因此,您无法通过尝试连接到 localhost 来浏览到在本地主机上运行的网站,您必须将其更改为 127.0.0.1
我怎样才能使Visual Studio 的内部 Web 服务器还
::1
监听
127.0.0.1
?
Visual Studio's internal development web-server only listens for connections from the local computer.
Unfortunatly, the web-server only binds to the IPv4 loopback address:
127.0.0.1
On machines with IPv6 enabled (i.e. Windows Vista, Window 7), it does not bind to the IPv6 loopback address:
::1
When you push play in Visual Studio, or open the web-site from the notification area icon, the browser launches and tries to connect to "localhost":
http://localhost:53289/WebSite/
localhost is not a real address, but an alias. On Vista and later it is defined as:
C:\Windows\System32\drivers\etc\hosts
::1 localhost
So you cannot browse to the web-site running on the local host by trying to connect to localhost, you have to change it to 127.0.0.1
How can i make Visual Studio's internal web-server also listen on
::1
in addition to
127.0.0.1
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,您不能将 IPv6 与 Visual Studio 的开发服务器一起使用。 不过,您可以使用 IIS 进行设置。
您可以在此处找到有关如何执行此操作的说明:http://blogs.iis.net/.../using-ipv6-with-iis7.aspx。
另一种选择是执行我之前所做的操作,即从主机文件中删除 IPv6 本地主机定义。 只需删除这一行:
确保在主机文件中包含对
127.0.0.1
的引用作为替代方案,否则您将遇到更大的问题。 您永远不需要使用localhost
作为::1
的别名,至少在世界完全切换到 IPv6 之前是这样,无论如何,这不会持续很长时间。As far as I know, you can not use IPv6 with Visual Studio's development server. You can set it up with IIS however.
You can find instructions on how to do this here: http://blogs.iis.net/.../using-ipv6-with-iis7.aspx.
Another option is to do what I've done before, which is to remove the IPv6 localhost definition from your hosts file. Just remove this line:
Make sure you include a reference to
127.0.0.1
in your hosts file as an alternative, otherwise you will have bigger problems. You should never need to uselocalhost
as an alias for::1
, at least until the world switches exclusively to IPv6, which won't be for a long time anyway.