如何在IIS Express中启用远程请求? Scott Guthrie wrote that is possible但他没有说怎么样 .
我在Visual Studio Professional 2015中安装了“Conveyor by Keyoti”解决了这个问题 . 传送带使用端口(45455)生成REMOTE地址(您的IP),以启用外部请求 . 例:
Conveyor允许您从网络上的外部平板电脑和手机或Android模拟器测试Web应用程序(无 http://10.0.2.2:<hostport> )
http://10.0.2.2:<hostport>
步骤如下:
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
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)
您可能需要进行三项更改 .
告诉IIS Express本身绑定到所有IP地址和主机名 . 在 .config 文件中 . 典型:
.config
VS 2015: $(solutionDir)\.vs\config\applicationhost.config
$(solutionDir)\.vs\config\applicationhost.config
<VS 2015: %userprofile%\My Documents\IISExpress\config\applicationhost.config
%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"空格的组使用双引号 .
everyone
具有高级安全性的启动/ Windows防火墙/入站规则/新规则...程序%ProgramFiles%\ IIS Express \ iisexpress.exe或端口8080 TCP
现在,当你启动 iisexpress.exe 时,你会看到一条消息,例如
iisexpress.exe
已成功注册网址“http:// *:8080 /”,用于网站“hello world”应用程序“/”
我记得几个月前尝试这个工作流时遇到了同样的问题 .
这就是为什么我专门为这种情况编写了一个简单的代理实用程序: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
编辑:只是提到它适用于noip.com
Scott Hanselman提供了一个很好的资源Working with SSL at Development Time is easier with IISExpress .
你所追求的是 Getting IIS Express to serve externally over Port 80
作为旁注:
netsh http add urlacl url=http://vaidesg:8080/ user=everyone
这仅适用于Windows的英文版本 . 如果您使用的是本地化版本,则必须将“everyone”替换为其他内容,例如:
"Iedereen"使用荷兰语版本时
"Jeder"使用德语版时
"Mindenki"使用匈牙利语版本时
否则您将收到错误(创建SDDL失败,错误:1332)
如果您正在使用Visual Studio,请按照以下步骤访问IP-Adress上的IIS-Express:
在Windows命令行中获取主机IP地址: ipconfig
ipconfig
GoTo
$(SolutionDir)\.vs\config\applicationHost.config
<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>
添加: <binding protocol="http" bindingInformation="*:62549:192.168.178.108"/>与你的IP地址
<binding protocol="http" bindingInformation="*:62549:192.168.178.108"/>
使用管理员权限运行Visual Studio,一切都应该有效
如果您尝试从远程连接,可能会查找一些防火墙问题
如果您已尝试Colonel Panic's answer但在Visual Studio中不起作用,请尝试以下操作:
在IIS Express配置中添加另一个 <binding />
<binding />
<bindings> <binding protocol="http" bindingInformation="*:8080:localhost" /> <binding protocol="http" bindingInformation="*:8080:hostname" /> </bindings>
最后,你必须 run Visual Studio as Admin
对我有所帮助的是,右击“IISExpress”图标,“显示所有应用程序” . 然后选择网站,我看到它使用了哪个aplicationhost.config,并且纠正完美 .
此问题的接受答案是使IIS Express与webmatrix一起使用的指南 . 我发现this guide在尝试使用VS 2010时更有用 .
我刚刚按照第3步和第4步(以管理员身份运行IIS Express),不得不暂时禁用我的防火墙以使其正常工作 .
这就是我使用Visual Studio 2015为Windows 10启用的远程访问,包括http和https:
第一步是将应用程序绑定到内部IP地址 . 运行 cmd - > ipconfig 以获取地址 . 打开文件 /{project folder}/.vs/config/applicationhost.config 并向下滚动,直到找到如下内容:
cmd
/{project folder}/.vs/config/applicationhost.config
<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:
bindings
<binding protocol="http" bindingInformation="*:12345:192.168.1.15" /> <binding protocol="https" bindingInformation="*:44300:192.168.1.15" />
将以下规则添加到防火墙,以管理员身份打开新的 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为 Administrator . 右键单击Web项目项目文件,然后选择 Properties . 转到 Web 选项卡,然后单击 Create Virtual Directory . 如果Visual Studio未以管理员身份运行,则可能会失败 . 现在一切都应该有效 .
Administrator
Properties
Web
Create Virtual Directory
您可以尝试设置端口转发,而不是尝试修改IIS Express配置,添加新的HTTP.sys规则或将Visual Studio作为管理员运行 .
基本上你需要将你的网站 IP:PORT 转发到你机器上的其他一些自由端口,但是在外部网络适配器上,而不是localhost .
IP:PORT
问题是IIS Express(至少在Windows 10上)绑定到 [::1]:port ,这意味着它会侦听IPv6端口 . 您需要考虑到这一点 .
[::1]:port
以下是我的工作方式 - http://programmingflow.com/2017/02/25/iis-express-on-external-ip.html
希望能帮助到你 .
我在Win 8.1和外部请求中使用IIS Express时遇到一些问题 .
我按照以下步骤调试外部请求:
安装IIS
配置Visual Studio以使用本地IIS(Web项目中的页面属性)
在IIS中创建一个独有的AppPool以使用我的应用程序
在我的项目中'm using Oracle Client and must be 32bits (64 bits don't使用Visual Studio)然后我需要在应用程序池中允许32位
配置Windows防火墙以允许端口80中的请求(入站规则)
它正在工作!
如果从Admin运行Visual Studio,则可以添加
要么
<binding protocol="https" bindingInformation="*:8443:*" />
成
我启用了本地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进行开发(然后允许远程连接),但反过来您必须始终以管理员身份运行...我不喜欢这样 .
我找到的最简单和最酷的方法是使用(设置需要2分钟):
https://ngrok.com/
它适用于在localhost上运行的任何东西 . 只需注册,运行一点exutable,无论你在localhost上运行什么,都可以从任何地方访问公共URL .
这对于向远程团队配合显示内容非常有用,无需摆弄IIS设置或防火墙 . 想要停止访问只是终止可执行文件 .
ngrok authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ngrok http -host-header=localhost 89230
假设89230是您的IIS Express端口
您甚至可以在免费计划上运行多个端口
我无法向我本地网络中的其他用户提供iis请求,我所要做的就是(除了上面的内容)重启了我的BT Hub路由器 .
这非常棒,甚至涵盖了具有漂亮域名的HTTPS:
http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx
如果以上链接消失,我在SO上的其他地方找不到真正令人敬畏的部分:
> C:\Program Files (x86)\IIS Express>IisExpressAdminCmd.exe Usage: > iisexpressadmincmd.exe <command> <parameters> Supported commands: > setupFriendlyHostnameUrl -url:<url> > deleteFriendlyHostnameUrl -url:<url> > setupUrl -url:<url> > deleteUrl -url:<url> > setupSslUrl -url:<url> -CertHash:<value> > setupSslUrl -url:<url> -UseSelfSigned > deleteSslUrl -url:<url> > > Examples: 1) Configure "http.sys" and "hosts" file for friendly > hostname "contoso": iisexpressadmincmd setupFriendlyHostnameUrl > -url:http://contoso:80/ 2) Remove "http.sys" configuration and "hosts" file entry for the friendly hostname "contoso": iisexpressadmincmd > deleteFriendlyHostnameUrl -url:http://contoso:80/
以上实用程序将为您注册SSL证书!如果使用-UseSelfSigned选项,则非常简单 .
如果你想以艰难的方式做事,非显而易见的部分是你需要告诉HTTP.SYS使用什么证书,如下所示:
netsh http add sslcert ipport=0.0.0.0:443 appid={214124cd-d05b-4309-9af9-9caa44b2b74a} certhash=YOURCERTHASHHERE
Certhash是您可以从MMC中的证书属性获得的“指纹” .
我做了以下,并能够连接:
1)将IIS快速配置绑定从本地主机更改为'*'
binding protocol =“http”bindingInformation =“:8888:”
2)在防火墙上定义入站规则以允许协议类型的特定端口:tcp
3)添加以下命令为您的端口添加网络配置:netsh http add urlacl url = http:// *:8888 / user = everyone
我通过使用反向代理方法解决了这个问题 .
我安装了wamp服务器并使用了apache web服务器的简单反向代理功能 .
我添加了一个新端口来监听Apache Web服务器(8081) . 然后我将代理配置添加为该端口的虚拟主机 .
<VirtualHost *:8081> ProxyPass / http://localhost:46935/ ProxyPassReverse / http://localhost:46935/ </VirtualHost>
[项目属性对话框]
使用VisualStudio 2017和NetCore API项目进行开发:
1)在Cmd-Box中:ipconfig / all确定IP地址
2a)在Project properties-> Debug选项卡中输入检索到的IP地址
2b)选择一个端口并将其附加到步骤2a的IP地址 .
3)在防火墙中添加允许规则以允许所选端口上的传入TCP流量(我的防火墙通过对话框触发:“阻止或向防火墙添加规则”) . 在这种情况下添加将做的伎俩 .
上述解决方案的缺点:
1)如果使用动态IP地址,则需要重新执行上述步骤,以防分配另一个IP地址 .
2)您的服务器现在有一个您可能忘记的开放端口,但是这个开放端口仍然是不受欢迎的访客的邀请 .
22 回答
我在Visual Studio Professional 2015中安装了“Conveyor by Keyoti”解决了这个问题 . 传送带使用端口(45455)生成REMOTE地址(您的IP),以启用外部请求 . 例:
Conveyor允许您从网络上的外部平板电脑和手机或Android模拟器测试Web应用程序(无
http://10.0.2.2:<hostport>
)步骤如下:
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
IIS团队网站上有一篇博客文章,现在解释如何enable remote connections on IIS Express . 以下是该帖子的相关部分:
您可能需要进行三项更改 .
告诉IIS Express本身绑定到所有IP地址和主机名 . 在
.config
文件中 . 典型:VS 2015:
$(solutionDir)\.vs\config\applicationhost.config
<VS 2015:
%userprofile%\My Documents\IISExpress\config\applicationhost.config
找到您网站的绑定元素,然后添加
everyone
是一个Windows组 . 对具有"Tout le monde"空格的组使用双引号 .现在,当你启动
iisexpress.exe
时,你会看到一条消息,例如我记得几个月前尝试这个工作流时遇到了同样的问题 .
这就是为什么我专门为这种情况编写了一个简单的代理实用程序: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之前,没有什么对我有用 .
以管理员身份打开命令提示符,然后运行
然后
假设您的Visual Studio项目在localhost:51123上打开,并且您想要访问外部IP地址x.x.x.x:81
编辑:只是提到它适用于noip.com
Scott Hanselman提供了一个很好的资源Working with SSL at Development Time is easier with IISExpress .
你所追求的是 Getting IIS Express to serve externally over Port 80
作为旁注:
这仅适用于Windows的英文版本 . 如果您使用的是本地化版本,则必须将“everyone”替换为其他内容,例如:
"Iedereen"使用荷兰语版本时
"Jeder"使用德语版时
"Mindenki"使用匈牙利语版本时
否则您将收到错误(创建SDDL失败,错误:1332)
如果您正在使用Visual Studio,请按照以下步骤访问IP-Adress上的IIS-Express:
在Windows命令行中获取主机IP地址:
ipconfig
GoTo
添加:
<binding protocol="http" bindingInformation="*:62549:192.168.178.108"/>
与你的IP地址
使用管理员权限运行Visual Studio,一切都应该有效
如果您尝试从远程连接,可能会查找一些防火墙问题
如果您已尝试Colonel Panic's answer但在Visual Studio中不起作用,请尝试以下操作:
在IIS Express配置中添加另一个
<binding />
最后,你必须 run Visual Studio as Admin
对我有所帮助的是,右击“IISExpress”图标,“显示所有应用程序” . 然后选择网站,我看到它使用了哪个aplicationhost.config,并且纠正完美 .
此问题的接受答案是使IIS Express与webmatrix一起使用的指南 . 我发现this guide在尝试使用VS 2010时更有用 .
我刚刚按照第3步和第4步(以管理员身份运行IIS Express),不得不暂时禁用我的防火墙以使其正常工作 .
这就是我使用Visual Studio 2015为Windows 10启用的远程访问,包括http和https:
第一步是将应用程序绑定到内部IP地址 . 运行
cmd
- >ipconfig
以获取地址 . 打开文件/{project folder}/.vs/config/applicationhost.config
并向下滚动,直到找到如下内容:在
bindings
下添加两个新绑定 . 如果您愿意,也可以使用HTTPS:将以下规则添加到防火墙,以管理员身份打开新的
cmd
提示符并运行以下命令:现在启动Visual Studio为
Administrator
. 右键单击Web项目项目文件,然后选择Properties
. 转到Web
选项卡,然后单击Create Virtual Directory
. 如果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
希望能帮助到你 .
我在Win 8.1和外部请求中使用IIS Express时遇到一些问题 .
我按照以下步骤调试外部请求:
安装IIS
配置Visual Studio以使用本地IIS(Web项目中的页面属性)
在IIS中创建一个独有的AppPool以使用我的应用程序
在我的项目中'm using Oracle Client and must be 32bits (64 bits don't使用Visual Studio)然后我需要在应用程序池中允许32位
配置Windows防火墙以允许端口80中的请求(入站规则)
它正在工作!
如果从Admin运行Visual Studio,则可以添加
<binding protocol="http" bindingInformation="*:8080:*" />
要么
<binding protocol="https" bindingInformation="*:8443:*" />
成
我启用了本地IIS,所以我刚刚为我的调试端口创建了一个重写规则...我认为这比其他方法更好更酷,因为一旦完成开发就更容易删除...这就是重写的样子 . .
VS还允许您直接使用本地IIS进行开发(然后允许远程连接),但反过来您必须始终以管理员身份运行...我不喜欢这样 .
我找到的最简单和最酷的方法是使用(设置需要2分钟):
https://ngrok.com/
它适用于在localhost上运行的任何东西 . 只需注册,运行一点exutable,无论你在localhost上运行什么,都可以从任何地方访问公共URL .
这对于向远程团队配合显示内容非常有用,无需摆弄IIS设置或防火墙 . 想要停止访问只是终止可执行文件 .
假设89230是您的IIS Express端口
您甚至可以在免费计划上运行多个端口
我无法向我本地网络中的其他用户提供iis请求,我所要做的就是(除了上面的内容)重启了我的BT Hub路由器 .
这非常棒,甚至涵盖了具有漂亮域名的HTTPS:
http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx
如果以上链接消失,我在SO上的其他地方找不到真正令人敬畏的部分:
以上实用程序将为您注册SSL证书!如果使用-UseSelfSigned选项,则非常简单 .
如果你想以艰难的方式做事,非显而易见的部分是你需要告诉HTTP.SYS使用什么证书,如下所示:
Certhash是您可以从MMC中的证书属性获得的“指纹” .
我做了以下,并能够连接:
1)将IIS快速配置绑定从本地主机更改为'*'
binding protocol =“http”bindingInformation =“:8888:”
2)在防火墙上定义入站规则以允许协议类型的特定端口:tcp
3)添加以下命令为您的端口添加网络配置:netsh http add urlacl url = http:// *:8888 / user = everyone
我通过使用反向代理方法解决了这个问题 .
我安装了wamp服务器并使用了apache web服务器的简单反向代理功能 .
我添加了一个新端口来监听Apache Web服务器(8081) . 然后我将代理配置添加为该端口的虚拟主机 .
[项目属性对话框]
使用VisualStudio 2017和NetCore API项目进行开发:
1)在Cmd-Box中:ipconfig / all确定IP地址
2a)在Project properties-> Debug选项卡中输入检索到的IP地址
2b)选择一个端口并将其附加到步骤2a的IP地址 .
3)在防火墙中添加允许规则以允许所选端口上的传入TCP流量(我的防火墙通过对话框触发:“阻止或向防火墙添加规则”) . 在这种情况下添加将做的伎俩 .
上述解决方案的缺点:
1)如果使用动态IP地址,则需要重新执行上述步骤,以防分配另一个IP地址 .
2)您的服务器现在有一个您可能忘记的开放端口,但是这个开放端口仍然是不受欢迎的访客的邀请 .