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


当前回答

在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)

其他回答

我已经启用了本地IIS,所以我刚刚创建了一个重写规则到我的调试端口…我认为这比其他方法更好,更酷,因为它更容易删除一旦我完成开发…下面是重写的样子。

<rewrite>
    <rules>
        <rule name="ReverseProxyInboundRule1" stopProcessing="true">
            <match url="^dev/(.*)" />
            <action type="Rewrite" url="http://localhost:47039/{R:1}" />
        </rule>
    </rules>
</rewrite>

VS也允许你直接使用本地IIS进行开发(然后允许远程连接),但是反过来你必须总是以管理员身份运行它…我不喜欢那样。

对于我来说,使用这个相对简单,直接:

通过在扩展对话框中搜索“输送机”下载Visual Studio扩展。然后就安装。

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

这是我用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不是以管理员身份运行,则可能会失败。现在一切都正常了。

在我找到iisexpress-proxy之前,什么都没用。

以管理员身份打开命令提示符,然后运行

npm install -g iisexpress-proxy

then

iisexpress-proxy 51123 to 81

假设您的Visual Studio项目在localhost:51123上打开,并且您想在外部IP地址x.x.x.x:81上访问

编辑:我目前正在使用ngrok

您可能需要做三个更改。

告诉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”应用程序“/”