如何在IIS Express中启用远程请求?Scott Guthrie写道,这是可能的,但他没有说明如何实现。


当前回答

我通过在Visual Studio Professional 2015中安装“输送机by Keyoti”解决了这个问题。输送机生成一个远程地址(您的IP),端口(45455)支持外部请求。例子:

输送机允许您从网络上的外部平板电脑和手机或Android模拟器测试web应用程序(没有http://10.0.2.2:<hostport>)

操作步骤如下:

https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti

其他回答

如果你从管理员运行Visual Studio,你可以添加

<装订协议=“http”bindingInformation=“8080:*”/>

or

<装订协议=“https”binps条=“*:8443:*”/>

into

%userprofile%\My Documents\IISExpress\config\applicationhost.config

我做了以下操作并成功连接:

1)将IIS快速配置绑定从本地主机更改为“*”

绑定协议="http" bindingInformation="*:8888:*"

2)在防火墙上定义入站规则,允许特定的端口用于协议类型:tcp

3)添加以下命令为您的端口添加网络配置: Netsh HTTP添加urlacl url=http://*:8888/ user=everyone

我发现最简单最酷的方法是使用(设置需要2分钟):

https://ngrok.com/

它将与本地主机上运行的任何东西一起工作。只要注册,运行小可执行程序,不管你在localhost上运行什么,你都可以从任何地方访问公共URL。

这对于向远程团队成员显示内容很有好处,无需摆弄IIS设置或防火墙。要停止访问只需终止可执行文件。

ngrok authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

ngrok http -host-header=localhost 89230

假设89230是您的IIS Express端口

您也可以运行多个端口,甚至在免费计划

如果你尝试过Panic上校的答案,但在Visual Studio中不起作用,试试这个:

在IIS Express配置中附加另一个<binding />

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

最后,你必须以管理员的身份运行Visual Studio

这是非常棒的,甚至包括HTTPS的漂亮域名:

http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx

非常棒的部分,我在其他地方找不到,以防上面的链接消失:

> C:\Program Files (x86)\IIS Express>IisExpressAdminCmd.exe Usage:
> iisexpressadmincmd.exe <command> <parameters> Supported commands:
>       setupFriendlyHostnameUrl -url:<url>
>       deleteFriendlyHostnameUrl -url:<url>
>       setupUrl -url:<url>
>       deleteUrl -url:<url>
>       setupSslUrl -url:<url> -CertHash:<value>
>       setupSslUrl -url:<url> -UseSelfSigned
>       deleteSslUrl -url:<url>
> 
> Examples: 1) Configure "http.sys" and "hosts" file for friendly
> hostname "contoso": iisexpressadmincmd setupFriendlyHostnameUrl
> -url:http://contoso:80/ 2) Remove "http.sys" configuration and "hosts" file entry for the friendly  hostname "contoso": iisexpressadmincmd
> deleteFriendlyHostnameUrl -url:http://contoso:80/

上面的实用程序将为您注册SSL证书!如果你使用-UseSelfSigned选项,这非常简单。

如果你想用困难的方式做事,不明显的部分是你需要告诉HTTP。SYS使用什么证书,像这样:

netsh http add sslcert ipport=0.0.0.0:443 appid={214124cd-d05b-4309-9af9-9caa44b2b74a} certhash=YOURCERTHASHHERE

Certhash是您可以从MMC中的证书属性中获得的“Thumbprint”。