如何在IIS Express中启用远程请求? Scott Guthrie wrote that is possible但他没有说怎么样。
IIS团队网站上有一篇博客文章,现在解释如何使用enable remote connections on IIS Express。以下是该帖子的相关部分:
在Vista和Win7上,从管理提示符运行以下命令:
netsh http add urlacl url=http://vaidesg:8080/ user=everyone
对于XP,首先安装Windows XP Service Pack 2支持工具。然后从管理提示符运行以下命令:
httpcfg set urlacl /u http://vaidesg1:8080/ /a D:(A;;GX;;;WD)
这就是我使用Visual Studio 2015为Windows 10启用的远程访问,包括http和https:
第一步是将应用程序绑定到内部IP地址。运行<binding />
- > <bindings>
<binding protocol="http" bindingInformation="*:8080:localhost" />
<binding protocol="http" bindingInformation="*:8080:hostname" />
</bindings>
获取地址。打开文件cmd
并向下滚动,直到找到如下内容:
ipconfig
在/{project folder}/.vs/config/applicationhost.config
下添加两个新绑定。如果您愿意,也可以使用HTTPS:
<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
提示符并运行以下命令:
<binding protocol="http" bindingInformation="*:12345:192.168.1.15" />
<binding protocol="https" bindingInformation="*:44300:192.168.1.15" />
现在启动Visual Studio作为cmd
。右键单击Web项目项目文件,然后选择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
。转到Administrator
选项卡,然后单击Properties
。如果Visual Studio未以管理员身份运行,则可能会失败。现在一切都应该有效。
Web
帮助我的是,右击“IIS Express”图标,“显示所有应用程序”。然后选择网站,我看到它使用了哪个applicationhost.config,并且纠正完美。
Create Virtual Directory
您可以尝试设置端口转发,而不是尝试修改IIS Express配置,添加新的HTTP.sys规则或将Visual Studio作为管理员运行。
基本上你需要将你的网站运行的转发到你机器上的其他一些免费端口,但是在外部网络适配器上,而不是localhost。
问题是IIS Express(至少在Windows 10上)绑定到this guide意味着它侦听IPv6端口。你需要考虑到这一点。
以下是我的工作方式 - IP:PORT
希望能帮助到你。
我在Win 8.1和外部请求中使用IIS Express时遇到一些问题。
我按照以下步骤调试外部请求:
它的工作原理!
如果从Admin运行Visual Studio,则可以只添加
[::1]:port
要么
http://programmingflow.com/2017/02/25/iis-express-on-external-ip.html
成
<binding protocol="http" bindingInformation="*:8080:*" />
我启用了一个本地IIS,所以我刚刚为我的调试端口创建了一个重写规则......我认为这比其他方法更好更酷,因为一旦开发完成就更容易删除...这就是重写的样子。 。
<binding protocol="https" bindingInformation="*:8443:*" />
VS还允许您直接使用本地IIS进行开发(然后允许远程连接)但反过来您必须始终以管理员身份运行...我不喜欢这样。
我找到的最简单和最酷的方法是使用(设置需要2分钟):
%userprofile%\My Documents\IISExpress\config\applicationhost.config
它适用于在localhost上运行的任何内容。只需注册,运行一点可执行文件,无论你在localhost上运行什么,都可以获得可以从任何地方访问的公共URL。
这对于向远程团队配合显示内容非常有用,无需摆弄IIS设置或防火墙。想要停止访问只是终止可执行文件。
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="^dev/(.*)" />
<action type="Rewrite" url="http://localhost:47039/{R:1}" />
</rule>
</rules>
</rewrite>
假设89230是您的IIS Express端口
即使在免费计划中,您也可以运行多个端口
我通过使用反向代理方法解决了这个问题。
我安装了wamp服务器并使用了apache web服务器的简单反向代理功能。
我添加了一个新端口来监听Apache Web服务器(8081)。然后我添加了代理配置作为该端口的虚拟主机。
https://ngrok.com/
我做了所有这些步骤,没有任何帮助我。而我需要的只是通过IIS Express运行我的应用程序...
ngrok authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ngrok http -host-header=localhost 89230
希望能帮助到你。
您可能需要进行三项更改。
.config
文件中。典型:
VS 2015:$(solutionDir)\.vs\config\applicationhost.config
<VS 2015:%userprofile%\My Documents\IISExpress\config\applicationhost.config
找到您网站的绑定元素,然后添加
<binding protocol="http" bindingInformation="*:8080:*" />
netsh http add urlacl url=http://*:8080/ user=everyone
everyone
是一个windows组。对于包含“Tout le monde”等空格的组,请使用双引号。
%ProgramFiles%\IIS Express\iisexpress.exe
或端口8080 TCP现在,当你启动iisexpress.exe
时,你会看到一条消息,例如
已成功为网站“hello world”应用程序“/”注册URL“http:// *:8080 /”
我无法向本地网络中的其他用户提供iis请求,我所要做的就是(除了上述内容之外)重新启动我的BT Hub路由器。
这非常棒,甚至覆盖了具有漂亮域名的HTTPS:
<VirtualHost *:8081>
ProxyPass / http://localhost:46935/
ProxyPassReverse / http://localhost:46935/
</VirtualHost>
如果以上链接消失,我在SO上的任何其他地方都找不到真正令人敬畏的部分:
以上实用程序将为您注册SSL证书!如果使用-UseSelfSigned选项,则非常简单。
如果你想以艰难的方式做事,那么非显而易见的部分是你需要告诉HTTP.SYS使用什么证书,如下所示:
http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx
Certhash是您可以从MMC中的证书属性获得的“指纹”。
我做了以下,并能够连接:
1)将IIS express配置绑定从本地主机更改为'*'
binding protocol =“http”bindingInformation =“*:8888:*”
2)在防火墙上定义入站规则以允许协议类型的特定端口:tcp
3)添加以下命令为您的端口添加网络配置:netsh http add urlacl url = http:// *:8888 / user = everyone
[项目属性对话框]
使用Visual Studio 2017和Net Core API项目进行开发:
1)在Cmd-Box中:ipconfig / all确定IP地址
2a)在Project properties-> Debug选项卡中输入检索到的IP地址
2b)选择一个端口并将其附加到步骤2a的IP地址。
3)在防火墙中添加允许规则以允许所选端口上的传入TCP流量(我的防火墙通过对话框触发:“阻止或向防火墙添加规则”)。在这种情况下添加将做的伎俩。
上述解决方案的缺点:
1)如果使用动态IP地址,则需要重新执行上述步骤,以防分配另一个IP地址。
2)您的服务器现在有一个您可能忘记的开放端口,但是这个开放端口仍然是不受欢迎的访客的邀请。
我记得几个月前尝试这个工作流时遇到了同样的问题。
这就是为什么我专门为这种情况写了一个简单的代理实用程序:https://github.com/icflorescu/iisexpress-proxy。
使用IIS Express Proxy,一切都变得非常简单 - 不需要“netsh http add urlacl url = vaidesg:8080 / user = everyone”或者搞乱你的“applicationhost.config”。
只需在命令提示符下发出:
iisexpress-proxy 8080 to 3000
...然后你可以将你的远程设备指向http://vaidesg:3000。
大多数时候更简单的更好。
在我找到iisexpress-proxy之前,没有什么对我有用。
以管理员身份打开命令提示符,然后运行
npm install -g iisexpress-proxy
然后
iisexpress-proxy 51123 to 81
假设您的Visual Studio项目在localhost:51123上打开,并且您希望访问外部IP地址x.x.x.x:81
编辑:我目前正在使用ngrok
一个很好的资源是Scott Hanselman的Working with SSL at Development Time is easier with IISExpress。
您所追求的是让IIS Express通过端口80从外部服务的部分
作为旁注:
netsh http add urlacl url=http://vaidesg:8080/ user=everyone
这仅适用于Windows的英文版本。如果您使用的是本地化版本,则必须将“everyone”替换为其他内容,例如:
否则您将收到错误(创建SDDL失败,错误:1332)
如果您正在使用Visual Studio,请按照以下步骤访问IP-Adress上的IIS-Express:
ipconfig
$(SolutionDir)\.vs\config\applicationHost.config
我在Visual Studio Professional 2015中安装了“Conveyor by Keyoti”解决了这个问题。传送带生成一个REMOTE地址(您的IP),其端口(45455)启用了外部请求。例:
<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>
Conveyor允许您从网络上的外部平板电脑和手机或Android模拟器(不使用<binding protocol="http" bindingInformation="*:62549:192.168.178.108"/>
)测试Web应用程序
步骤如下:
如果您已尝试过http://10.0.2.2:<hostport>
但无法在Visual Studio中运行,请尝试以下操作:
在IIS Express配置中添加另一个https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
Colonel Panic's answer
最后,您必须以管理员身份运行Visual Studio