是否可以使用自定义的主机头/绑定与IIS7防爆preSS? [英] Is it possible to use custom host headers / bindings with IIS7 Express?

查看:194
本文介绍了是否可以使用自定义的主机头/绑定与IIS7防爆preSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想配置一个新的 ASP.NET MVC3 使用的 IIS7 EX preSS (我的本地开发机)使用自定义域名

如:

  1. 在我的本地开发计算机。
  2. 一脚踹开我的网页浏览器
  3. 转到 http://dev.www.mydomain.com
  4. 在我的Visual Studio MVC项目踢

我砍死我的hosts文件,包括:(是的,我将文件保存..这也意味着我不得不启用管理员权限...

  127.0.0.1 dev.www.mydomain.com
 

我只是不知道如何使用IIS7 EX preSS获得配置做到这一点。

我去了 MVC项目=>属性=>网络,也如下: -

然后试图运行的网站...

谁能帮助?

解决方案
  1. 如果正在运行,停止正在运行的网站

  2. 打开%USERPROFILE%\文档\ iisex preSS \设置\对ApplicationHost.config

  3. 找到你感兴趣的网站,它会像

    绑定

    <约束力的议定书=HTTPbindingInformation =*:<您的端口数>:本地主机/>

  4. 现在添加一个类似的条目<约束力的议定书=HTTPbindingInformation =*:<您的端口>:dev.www.mydomain.com/> 略低于上述bindig项。

  5. 再次运行网站

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


更新纯克罗梅:

此外这一点,我们需要做到以下几点。这些评论在我的web.config文件的顶部(以及一些其他的东西......)。

  1)的netsh的http添加urlacl URL = HTTP://localhost.www.foo.com:80 /用户=大家
   netsh的HTTP添加urlacl URL = HTTP://localhost.foo.com:80 /用户=大家
   netsh的HTTP添加urlacl URL = HTTP://localhost.foobar.com.au:80 /用户=大家
   netsh的HTTP添加urlacl URL = HTTP://localhost.pewpew.com:80 /用户=大家
   ... 等等 ...
   注意:删除urlacl:netsh的HTTP删除urlacl URL =< URL在这里> ..如http://foo.com:80

2)......我们需要编辑的主要IIS7 EX preSS配置文件定义的URL将被接受,每个Web -site-
    文件:C:\用户\<用户名> \文档\ IISEx preSS \设置\对ApplicationHost.config
<绑定>
    <约束力的议定书=HTTPbindingInformation =*:1200:本地主机/>
    <约束力的议定书=HTTPbindingInformation =*:80:localhost.www.foo.com/>
    <约束力的议定书=HTTPbindingInformation =*:80:localhost.foo.com/>
    <约束力的议定书=HTTPbindingInformation =*:80:localhost.foobar.com.au/>
    <约束力的议定书=HTTPbindingInformation =*:80:localhost.pewpew.com/>
< /绑定>
 

I'm trying to configure a new ASP.NET MVC3 using IIS7 express (on my local development machine) to use a custom domain name.

eg.

  1. my local dev machine.
  2. kick open my web browser
  3. goto http://dev.www.mydomain.com
  4. my visual studio mvc project kicks in

I've hacked my hosts file to include (yes, i saved the file .. which also meant i had to have admin rights enabled ...

127.0.0.1 dev.www.mydomain.com

I just can't figure out how to use IIS7 express to get configured to do this.

I went to MVC Project => Properties => Web and did the following :-

Then tried to run the site...

Can anyone help?

解决方案

  1. Stop currently running site if it is running

  2. Open %userprofile%\documents\iisexpress\config\applicationhost.config

  3. Locate the site you are interested in and it would have a binding like

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

  4. Now add a similar entry <binding protocol="http" bindingInformation="*:<your-port>:dev.www.mydomain.com" /> just below the above bindig entry.

  5. run the site again

NOTE: You must start visual studio as administrator because non-localhost binding requires administrator privileges


Update By Pure Krome:

Further to this, we need to do the following. These comments are in the top of my web.config (along with a few other stuff...).

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>

这篇关于是否可以使用自定义的主机头/绑定与IIS7防爆preSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆