16

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

例如。

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

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

127.0.0.1 dev.www.mydomain.com

我只是不知道如何使用 IIS7 express 来配置执行此操作。

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

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

任何人都可以帮忙吗?

4

2 回答 2

19
  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,因为非本地主机绑定需要管理员权限


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>
于 2011-03-17T15:20:03.263 回答
-1

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

  1. 从菜单中选择项目 => [项目] 属性
  2. 点击“网络”部分
  3. 选择“使用自定义Web 服务器”选项,并将服务器 URL 设置为“http://dev.www.my-domain.com”
于 2011-05-10T18:47:07.877 回答