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


当前回答

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

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

or

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

into

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

其他回答

我通过在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

一个很好的资源是Scott Hanselman的IISExpress更容易在开发阶段使用SSL。

您要了解的是如何让IIS Express通过端口80为外部提供服务

这是我用Visual Studio 2015为Windows 10启用远程访问所做的,包括http和https:

第一步是将应用程序绑定到内部IP地址。执行cmd -> ipconfig命令获取地址。打开文件/{项目文件夹}/.vs/config/applicationhost。配置并向下滚动,直到你找到像这样的东西:

<site name="Project.Web" id="2">
    <application path="/">
        <virtualDirectory path="/" physicalPath="C:\Project\Project.Web" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:12345:localhost" />
    </bindings>
</site>

在bindings下添加两个新绑定。如果你喜欢,你也可以使用HTTPS:

<binding protocol="http" bindingInformation="*:12345:192.168.1.15" />
<binding protocol="https" bindingInformation="*:44300:192.168.1.15" />

将以下规则添加到您的防火墙,以admin身份打开一个新的cmd提示符,并运行以下命令:

netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=12345 profile=private remoteip=localsubnet action=allow

netsh advfirewall firewall add rule name="IISExpressWebHttps" dir=in protocol=tcp localport=44300 profile=private remoteip=localsubnet action=allow

现在以管理员身份启动Visual Studio。右键单击web项目项目文件并选择属性。进入“Web”页签,单击“创建虚拟目录”。如果Visual Studio不是以管理员身份运行,则可能会失败。现在一切都正常了。

我用反向代理的方法解决了这个问题。

我安装了wamp服务器,使用了apache web服务器的简单反向代理功能。

我添加了一个新的端口来监听Apache web服务器(8081)。然后我为该端口添加了虚拟主机代理配置。

<VirtualHost *:8081>
ProxyPass / http://localhost:46935/
ProxyPassReverse / http://localhost:46935/
</VirtualHost>

我无法在我的本地网络中为其他用户提供iis请求,我所要做的(除了上面提到的)就是重新启动我的BT Hub路由器。