如果正在运行,则停止当前运行的站点
%userprofile%\documents\iisexpress\config\applicationhost.config
为 VS2015+打开:$(solutionDir)\.vs\config\applicationhost.config
找到您感兴趣的网站,它会有一个类似的绑定
<binding protocol="http" bindingInformation="*:<your-port-number>:localhost" />
<binding protocol="http" bindingInformation="*:<your-port>:dev.www.mydomain.com" />
现在在上面的 bindig 条目下方添加一个类似的条目。
再次运行该站点
注意:您必须以管理员身份启动 Visual Studio,因为非本地主机绑定需要管理员权限
Pure Krome 更新:
除此之外,我们还需要做以下事情。这些评论在我的 web.config 的顶部(以及其他一些东西......)。
1) netsh http add urlacl url=http://localhost.www.foo.com:80/ user=everyone
netsh http add urlacl url=http://localhost.foo.com:80/ user=everyone
netsh http add urlacl url=http://localhost.foobar.com.au:80/ user=everyone
netsh http add urlacl url=http://localhost.pewpew.com:80/ user=everyone
... etc ...
NOTE: to remove a urlacl: netsh http delete urlacl url=<url in here> .. eg http://foo.com:80
2) ... and we need to edit the main IIS7 express config file to define the url's which will be accepted, per web -site-
File: C:\Users\<UserName>\Documents\IISExpress\config\applicationhost.config
<bindings>
<binding protocol="http" bindingInformation="*:1200:localhost" />
<binding protocol="http" bindingInformation="*:80:localhost.www.foo.com" />
<binding protocol="http" bindingInformation="*:80:localhost.foo.com" />
<binding protocol="http" bindingInformation="*:80:localhost.foobar.com.au" />
<binding protocol="http" bindingInformation="*:80:localhost.pewpew.com" />
</bindings>