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


当前回答

您可能需要做三个更改。

告诉IIS Express本身绑定到所有ip地址和主机名。在你的。config文件中。通常: VS 2015: $ (solutionDir) \ .vs \ config \ applicationhost.config < VS 2015: %userprofile%\My Documents\IISExpress\config\applicationhost.config

找到站点的绑定元素,然后添加

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

设置Windows中名为“http.sys”的部分。以管理员身份执行如下命令:

    netsh http add urlacl url=http://*:8080/ user=everyone

每个人都是一个windows组。对于有空格的组使用双引号,如“Tout le monde”。

允许IIS Express通过Windows防火墙。 启动/ Windows防火墙高级安全/入站规则/新规则… 程序%ProgramFiles%\IIS Express\iisexpress.exe 或端口8080 TCP

现在,当您启动iisexpress.exe时,您应该看到如下消息

成功注册网址“http://*:8080/”网站“hello world”应用程序“/”

其他回答

您可能需要做三个更改。

告诉IIS Express本身绑定到所有ip地址和主机名。在你的。config文件中。通常: VS 2015: $ (solutionDir) \ .vs \ config \ applicationhost.config < VS 2015: %userprofile%\My Documents\IISExpress\config\applicationhost.config

找到站点的绑定元素,然后添加

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

设置Windows中名为“http.sys”的部分。以管理员身份执行如下命令:

    netsh http add urlacl url=http://*:8080/ user=everyone

每个人都是一个windows组。对于有空格的组使用双引号,如“Tout le monde”。

允许IIS Express通过Windows防火墙。 启动/ Windows防火墙高级安全/入站规则/新规则… 程序%ProgramFiles%\IIS Express\iisexpress.exe 或端口8080 TCP

现在,当您启动iisexpress.exe时,您应该看到如下消息

成功注册网址“http://*:8080/”网站“hello world”应用程序“/”

我在win8.1中使用IIS Express和外部请求时遇到一些问题。

我遵循以下步骤调试外部请求:

安装IIS 配置Visual Studio以使用本地IIS (Web项目中的页面属性) 在IIS中创建一个专用的appool来使用我的应用程序 在我的项目中,我使用Oracle客户端,必须是32位(64位不使用Visual Studio),然后我需要在应用程序池中允许32位 配置Windows防火墙以允许端口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不是以管理员身份运行,则可能会失败。现在一切都正常了。

在IIS团队网站上有一篇博客文章解释了如何在IIS Express上启用远程连接。以下是那篇文章的相关部分总结:

在Vista和Win7上,在管理提示符下运行以下命令: Netsh HTTP添加urlacl url=http://vaidesg:8080/ user=everyone 对于XP系统,首先安装Windows XP Service Pack 2 Support Tools。然后在管理提示符下运行以下命令: httpcfg set urlacl /u http://vaidesg1:8080/ /a D:(a;;GX;;;WD)

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

https://ngrok.com/

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

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

ngrok authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

ngrok http -host-header=localhost 89230

假设89230是您的IIS Express端口

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