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

查看:22
本文介绍了配置 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.

我所有的研究都将我发送到此博客条目:http://blogs.iis.net/vaidyg/archive/2010/07/29/serving-external-traffic-with-webmatrix-beta.aspx,很有帮助但似乎没有显示如何为在 Visual Studio 中启动的项目配置绑定(我在屏幕截图中找不到屏幕,并且我在 applicationhost.config 中编辑了绑定信息,但是当我运行来自视觉工作室的网站).

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=DOMAINusername

在 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天全站免登陆