配置IIS Express以从外部访问VS2010项目 [英] Configure IIS Express for external access to VS2010 project

查看:88
本文介绍了配置IIS Express以从外部访问VS2010项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在VS2010中开发一个项目,并且能够通过IIS Express在本地查看我的网站.我想启用通过网络的外部访问.

I am developing a project in VS2010 and am able to view my site locally via IIS Express. I would like to enable external access over the network.

我的所有研究都将我发送到此博客条目:

All my research has sent me to this blog entry: http://blogs.iis.net/vaidyg/archive/2010/07/29/serving-external-traffic-with-webmatrix-beta.aspx, which is helpful but does not seem to show how to configure bindings for a project started in visual studio (I cannot find the screen in the screenshots, and I have edited binding info in applicationhost.config, but it does not seem to be reflected when I run the site from visual studio).

推荐答案

1 编辑了applicationhost.config文件(位于文档的IISExpress文件夹中)后,您的网站绑定应如下所示:

1 After editing applicationhost.config file (located in the IISExpress folder in your documents), your site bindings should look like below:

<bindings>
  <binding protocol="http" bindingInformation="*:8080:*" />
</bindings>

绑定由三部分组成.首先是IP地址或列表,或者在这种情况下为通配符.其次是端口号,其次是主机名,列表或通配符(用于通过Host标头进行过滤).出于开发目的,此处最适合使用通配符,因为您可能会使用唯一的端口.

Bindings consist of three parts. Firstly an IP address or list, or as in this case, a wildcard. Secondly the port number, and thirdly a hostname, or list, or wildcard (for filtering by Host header). For development purposes, a wildcard is most suitable here as you will likely be using a unique port.

2 由于您使用的是非本地主机绑定,因此需要其他权限.您可以以管理员身份运行VS,或者最好您应该添加URL ACL 以授予所需的权限.在下面的示例中,权限授予每个人,但您可以使用自己的用户名.

2 Because you are using non-localhost binding, additional permissions are required. You could run VS as administrator, or preferably you should add URL ACLs to grant the required permissions. In the example below permission is given to everyone, but you could use your own username.

注意:urlacl必须与绑定完全匹配.因此,对于http://*:8080urlacl将允许*:8080:*的绑定,但不允许*:8080:localhost的绑定,即使后者是前者的子集. 这意味着,如果您在applicationhost.config中列出主机头而不是使用通配符,则必须为每个主机头添加匹配的urlacl.

Note: The urlacl must exactly match the binding. So a urlacl for http://*:8080 will allow a binding of *:8080:*, but not a binding of *:8080:localhost even though the latter is a subset of the former. this means if, instead of using a wildcard, you list host headers in applicationhost.config, you must add a matching urlacl for each.

为外部流量配置HTTP.sys的步骤类似于将站点设置为使用保留端口.在Windows 7或Windows Vista上,从提升的命令提示符下,运行以下命令:

The steps for configuring HTTP.sys for external traffic are similar to setting up a site to use a reserved port. On Windows 7 or Windows Vista, from an elevated command prompt, run the following command:

netsh http add urlacl url=http://*:8080/ user=DOMAIN\username

在Windows XP上,从提升权限的命令提示符下运行以下命令:

On Windows XP, run the following command from an elevated command prompt:

httpcfg set urlacl /u http://*:8080/ /a D:(A;;GX;;;WD)

注释2 如果以管理员身份运行VS或添加ACL条目不能解决问题,请从命令行运行IIS Express,并检查是否存在任何绑定注册失败消息.要从命令行开始,请输入以下命令:

Note 2 If running VS as administrator or adding ACL entries doesn't solve your problem, then run IIS Express from the command line and check if there are any binding registration failure messages. To start from the command line, give this command:

iisexpress.exe /site:"your-site-name"

3 最后,您将需要适当的防火墙条目.为此,最简单的方法是使用具有高级安全性的Windows防火墙"控制台.

3 Finally you will need appropriate firewall entries. For this it is easiest to use the "Windows Firewall with Advanced Security" console.

在入站规则"下,选择新规则...".

Under "Inbound Rules" choose "New Rule...".

  • 规则类型为自定义".
  • 程序即服务->自定义...->仅适用于服务. (尽管IIS Express不是一项服务,但它使用的HTTP多路复用器却是).
  • 协议是TCP
  • 特定端口:列出所有IIS Express绑定的所有端口.您可以回到此规则并随时添加端口. (如果这变得很烦人,则可以添加一个范围,例如40000-65534,它覆盖了Visual Studio使用的整个范围,但是请注意,这不太安全.)
  • 操作为允许连接"
  • 个人资料将是以下内容之一.如有疑问,请选择域+私有".
    • 域",如果您的是公司桌面,并且仅在本地域上运行
    • 域+私有":如果您是非公司环境中的私有开发计算机,或者是在家工作时也需要工作的公司笔记本电脑.
    • 域,专用和公用",如果您需要在非专用网络上进行演示.
    • Rule Type is "Custom".
    • Program is Services->Customize...->Apply to services only. (Although IIS Express is not a service, the HTTP multiplexer it uses is).
    • Protocol is TCP
    • Specific Ports: List all the ports for all of your IIS Express bindings. You can come back to this rule and add ports at any time. (If this becomes tiresome, you might add a range such as 40000-65534 which covers the entire range used by Visual Studio, but be aware this is less secure).
    • Action is "Allow the connection"
    • Profile will be one of the following. If in doubt, choose "Domain + private".
      • "Domain", If yours is a corporate desktop and will only be running on the local domain
      • "Domain + Private" If yours is a private development machine in a non-corporate environment, or a corporate laptop which also needs to work when working from home.
      • "Domain, Private and Public", if you need to do demonstrations on non-private networks.

      这篇关于配置IIS Express以从外部访问VS2010项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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