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


当前回答

如果你正在使用Visual Studio,那么按照以下步骤通过ip地址访问IIS-Express:

Get your host IP-Adress: ipconfig in Windows Command Line GoTo $(SolutionDir)\.vs\config\applicationHost.config Find <site name="WebApplication3" id="2"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="C:\Users\user.name\Source\Repos\protoype-one\WebApplication3" /> </application> <bindings> <binding protocol="http" bindingInformation="*:62549:localhost" /> </bindings> </site> Add: <binding protocol="http" bindingInformation="*:62549:192.168.178.108"/> with your IP-Adress Run your Visual Studio with Administrator rights and everything should work See post from Andrii how to configure Firewall: here

其他回答

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

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

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

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

您可以尝试设置端口转发,而不是尝试修改IIS Express配置,添加新的HTTP。sys规则或以管理员身份运行Visual Studio。

基本上,你需要将你的网站运行的IP:PORT转发到你机器上的其他空闲端口,但在外部网络适配器上,而不是localhost。

问题是IIS Express(至少在Windows 10上)绑定到[::1]:port,这意味着它侦听IPv6端口。你需要考虑到这一点。

以下是我如何做到这一点- http://programmingflow.com/2017/02/25/iis-express-on-external-ip.html

希望能有所帮助。

[项目属性对话框]

使用VisualStudio 2017和NetCore api项目进行开发:

1)在Cmd-Box: ipconfig /all中确定ip地址

2a)在“项目属性->调试”选项卡中输入检索到的ip地址

2b)选择一个端口,并将其附加到步骤2a中的ip地址。

3)在防火墙中添加allow规则,允许从所选端口进入tcp流量 (我的防火墙被一个对话框触发:“阻止或添加规则到防火墙”)。在这种情况下,加法就可以了。

上述方案的缺点:

1)如果你使用动态ip地址,你需要重做上述步骤,以防另一个ip地址已被分配。

2)你的服务器现在有一个开放的端口,你可能会忘记,但这个开放端口仍然是一个邀请不受欢迎的客人。

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

https://ngrok.com/

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

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

ngrok authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

ngrok http -host-header=localhost 89230

假设89230是您的IIS Express端口

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

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