【问题标题】:Is it possible to use custom host headers / bindings with IIS7 Express?是否可以在 IIS7 Express 中使用自定义主机头/绑定?
【发布时间】:2011-03-17 11:09:54
【问题描述】:

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

例如。

  1. 我的本地开发机器。
  2. 打开我的网络浏览器
  3. 转到http://dev.www.mydomain.com
  4. 我的 Visual Studio mvc 项目启动

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

127.0.0.1 dev.www.mydomain.com

我只是不知道如何使用 IIS7 express 进行配置。

我去了MVC Project => Properties => Web并做了以下事情:-

然后尝试运行该站点...

谁能帮忙?

【问题讨论】:

    标签: .net iis-express visual-studio-2010


    【解决方案1】:
    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" />

    5. 再次运行网站

    注意:您必须以管理员身份启动 Visual Studio,因为非本地主机绑定需要管理员权限


    Pure Krome 更新:

    除此之外,我们还需要执行以下操作。这些 cmets 在我的 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>
    

    【讨论】:

    • @user578913 - 骗我..你是认真的吗??????我现在必须让团队中的每个成员手动编辑他们的 apphost.config 文件??哇! :(
    • 恐怕你必须这样做@pure ...但我当然希望他们能解决这个问题。你也可以为它创建一个小的 power shell 脚本。
    • @Syska - 是的,我忘记了这个问题。自从我得到这个答案以来,我一直在使用这种技术。效果很好!我刚刚在我们的 web.config 顶部有一条评论,其中包含命令(ps 命令行)如何执行此操作。事实上,我会更新这个答案。
    • YOWZA WOWZA 这很有帮助。 YOWZA WOWZA
    【解决方案2】:

    我已经成功地调试了一个与上面类似的 IIS7 绑定站点。您似乎缺少的唯一步骤是在您的项目中:

    1. 从菜单中选择项目 => [项目] 属性
    2. 点击“Web”部分
    3. 选择“使用自定义 Web Server”选项,并将Server Url设置为“http://dev.www.my-domain.com”

    【讨论】:

    • 问题是关于 IIS Express。 :)
    猜你喜欢
    • 2014-06-10
    • 1970-01-01
    • 2014-03-30
    • 2020-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多