是否可以在IIS7 Express中使用自定义主机标头/绑定?

Pur*_*ome 16 .net visual-studio-2010 visual-studio-2010-sp1 iis-express

我正在尝试使用IIS7 express(在我的本地开发机器上)配置新的ASP.NET MVC3以使用自定义域名.

例如.

  1. 我的本地开发机器.
  2. 踢我的网络浏览器
  3. 转到http://dev.www.mydomain.com
  4. 我的视觉工作室mvc项目开始了

我已经攻击了我的主机文件以包含(是的,我保存了文件..这也意味着我必须启用管理员权限...

127.0.0.1 dev.www.mydomain.com
Run Code Online (Sandbox Code Playgroud)

我只是想不通如何使用IIS7 express来配置这样做.

我去了MVC Project => Properties => Web并做了以下事情: - 在此输入图像描述

然后试图运行该网站... 在此输入图像描述

有人可以帮忙吗?

vik*_*all 18

  1. 如果正在运行,则停止当前正在运行的站

  2. 打开%userprofile%\documents\iisexpress\config\applicationhost.config
    VS2015 +:$(solutionDir)\.vs\config\applicationhost.config

  3. 找到您感兴趣的网站,它会有类似的绑定

    <binding protocol="http" bindingInformation="*:<your-port-number>:localhost" />

  4. 现在<binding protocol="http" bindingInformation="*:<your-port>:dev.www.mydomain.com" />在上面的bindig条目下面添加一个类似的条目.

  5. 再次运行该网站

注意:您必须以管理员身份启动visual studio,因为非localhost绑定需要管理员权限


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>
Run Code Online (Sandbox Code Playgroud)