如何在 IIS Express 中启用外部请求?
如何在 IIS Express 中启用远程请求? Scott Guthrie 写道这是可能的,但是他没有说怎么做。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何在 IIS Express 中启用远程请求? Scott Guthrie 写道这是可能的,但是他没有说怎么做。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(28)
IIS 团队网站上有一篇博客文章,现在解释如何在 IIS Express 上启用远程连接。以下是该帖子的相关部分总结:
There's a blog post up on the IIS team site now explaining how to enable remote connections on IIS Express. Here is the pertinent part of that post summarized:
您可能需要进行三项更改。
.config
文件中。通常:$(solutionDir)\.vs\config\applicationhost.config
%userprofile%\My Documents\IISExpress\config\applicationhost.config
与 2015 年相比
找到站点的绑定元素,然后添加
其中
everyone
是 Windows 组。对于带有空格的组(如“Tout le monde”)使用双引号。允许 IIS Express 通过 Windows 防火墙。
<块引用>
启动/具有高级安全性的 Windows 防火墙/入站规则/新规则...
程序
%ProgramFiles%\IIS Express\iisexpress.exe
或端口 8080 TCP
现在,当您启动 iisexpress.exe 时,您应该会看到一条消息,例如
There are three changes you might need to make.
.config
file. Typically:$(solutionDir)\.vs\config\applicationhost.config
%userprofile%\My Documents\IISExpress\config\applicationhost.config
Find your site's binding element, and add
Where
everyone
is a windows group. Use double quotes for groups with spaces like "Tout le monde".Allow IIS Express through Windows firewall.
Now when you start
iisexpress.exe
you should see a message such as在我找到 iisexpress-proxy 之前,一切都对我不起作用。
以管理员身份打开命令提示符,然后运行
,然后
假设您的 Visual Studio 项目在 localhost:51123 上打开,并且您想要访问外部 IP 地址 xxxx:81
编辑:我当前正在使用
ngrok
Nothing worked for me until I found iisexpress-proxy.
Open command prompt as administrator, then run
then
assuming your Visual Studio project opens on localhost:51123 and you want to access on external IP address x.x.x.x:81
Edit: I am currently using
ngrok
我记得几个月前尝试此工作流程时遇到了同样的问题。
这就是为什么我专门为这种情况编写了一个简单的代理实用程序: https://github.com/icflorescu/iisexpress-proxy< /a>.
使用 IIS Express 代理,一切都变得非常简单 - 无需“netsh http add urlacl url=vaidesg:8080/” user=everyone”或者搞乱你的“applicationhost.config”。
只需在命令提示符中发出以下命令:
iisexpress-proxy 8080 to 3000
...然后您就可以将远程设备指向http://vaidesg: 3000。
大多数时候越简单越好。
I remember running into the same problems while trying this workflow a few months ago.
Which is why I wrote a simple proxy utility specifically for this kind of scenario: https://github.com/icflorescu/iisexpress-proxy.
Using the IIS Express Proxy, it all becomes quite simple – no need to “netsh http add urlacl url=vaidesg:8080/ user=everyone” or to mess up with your “applicationhost.config”.
Just issue this in command prompt:
iisexpress-proxy 8080 to 3000
…and then you can point your remote devices to http://vaidesg:3000.
Most of the times simpler IS better.
如果您使用 Visual Studio,请按照以下步骤通过 IP 地址访问 IIS-Express:
获取主机 IP 地址:在 Windows 命令行中
ipconfig
GoTo
查找
添加:
<绑定协议="http" bindingInformation="*:62549:192.168.178.108"/>
与您的 IP 地址
使用管理员权限运行 Visual Studio,一切都应该正常
查看 Andrii 的帖子如何配置防火墙:此处
If you're working with Visual Studio then follow these steps to access the IIS-Express over IP-Adress:
Get your host IP-Adress:
ipconfig
in Windows Command LineGoTo
Find
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
作为旁注:
这仅适用于英文版本的 Windows。如果您使用本地化版本,则必须将“everyone”替换为其他内容,例如:
否则您将得到错误(创建 SDDL 失败,错误:1332)
As a sidenote to this:
This will only work on English versions of Windows. If you are using a localized version you have to replace "everyone" with something else, for example:
Otherwise you will get an error (Create SDDL failed, Error: 1332)
Scott Hanselman 的 使用 IISExpress 在开发时使用 SSL 更容易 是一个很好的资源。
您所关注的是让 IIS Express 通过端口 80 向外部提供服务部分
A good resource is Working with SSL at Development Time is easier with IISExpress by Scott Hanselman.
What you're after is the section Getting IIS Express to serve externally over Port 80
我通过在 Visual Studio Professional 2015 中安装“Conveyor by Keyoti”解决了这个问题。Conveyor 生成一个带有启用外部请求的端口 (45455) 的远程地址(您的 IP)。示例:
Conveyor 允许您从网络上的外部平板电脑和手机或 Android 模拟器测试 Web 应用程序(不带
http://10.0.2.2:
)步骤位于以下链接中:
https://marketplace.visualstudio.com /items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
I solved it with the installation of "Conveyor by Keyoti" in Visual Studio Professional 2015. Conveyor generate a REMOTE address (your IP) with a port (45455) that enable external request. Example:
Conveyor allows you test web applications from from external tablets and phones on your network or from Android emulators (without
http://10.0.2.2:<hostport>
)The steps are in the following link :
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
结合此线程中的答案,这就是我修复它的方法(Visual Studio 2019):
以管理员身份启动 Visual Studio 并像平常一样运行您的 Web 服务。
在任务栏上找到 IIS Express 图标,右键单击它,然后单击“显示所有应用程序”。
选择您的 Web 服务并记下下面显示的配置路径。单击配置文件将其打开进行编辑。
在此配置文件中找到您的网络服务(例如搜索您的端口),然后找到如下行:
*
:你的端口:localhost在后面添加一个新行,如下所示:
:
您的端口:*
在这种情况下,无需创建绑定将来可能会更改的特定 IP 地址。
我希望这对那里的人有帮助。
Combining answers in this thread, this is how I fixed it(Visual Studio 2019):
Start Visual Studio as an Administrator and Run your Web Service as you normally do.
Find IIS Express icon on the taskbar, right click on it then click "Show All Applications".
Select your Web Service and note the config path displayed below. Click on the config file to open it for editing.
Find your web service(example search for your port) in this config file then find a line like this:
*
:yourport:localhostAdd a new line after that like this:
:
yourport:*
In this case no need to create bindings with specific ip address which could change in the future.
I hope this helps someone out there.
这就是我使用 Visual Studio 2015 对 Windows 10 所做的操作,以启用远程访问(使用 http 和 https):
第一步是将您的应用程序绑定到您的内部 IP 地址。运行
cmd
->ipconfig
获取地址。打开文件/{项目文件夹}/.vs/config/applicationhost.config
并向下滚动,直到找到如下内容:在
bindings
下添加两个新绑定。如果愿意,您也可以使用 HTTPS:将以下规则添加到防火墙,以管理员身份打开新的
cmd
提示符并运行以下命令:现在以
管理员
身份启动 Visual Studio >。右键单击 Web 项目项目文件并选择Properties
。转到Web
选项卡,然后单击创建虚拟目录
。如果 Visual Studio 不以管理员身份运行,这可能会失败。现在一切都应该可以了。This is what I did for Windows 10 with Visual Studio 2015 to enable remote access, both with http and https:
First step is to bind your application to your internal IP address. Run
cmd
->ipconfig
to get the address. Open the file/{project folder}/.vs/config/applicationhost.config
and scroll down until you find something like this:Add two new bindings under
bindings
. You can use HTTPS as well if you like:Add the following rule to your firewall, open a new
cmd
prompt as admin and run the following commands:Now start Visual Studio as
Administrator
. Right click the web projects project file and selectProperties
. Go to theWeb
tab, and clickCreate Virtual Directory
. If Visual Studio is not run as Administrator this will probably fail. Now everything should work.对我有帮助的是右键单击“IISExpress”图标,“显示所有应用程序”。然后选择该网站,我看到它使用哪个 aplicationhost.config,并且更正进行得非常完美。
What helped me, was right clicking the 'IISExpress' icon, 'Show All applications'. Then selecting the website and I saw which aplicationhost.config it uses, and the the correction went perfectly.
我发现的最简单、最酷的方法是使用(设置需要 2 分钟):
https://ngrok.com/
它将与本地主机上运行的任何东西一起工作。只需注册,运行一点可执行文件,无论您在本地主机上运行什么,都会获得可以从任何地方访问的公共 URL。
这非常适合向远程团队成员展示内容,无需摆弄 IIS 设置或防火墙。想要停止访问只需终止可执行文件即可。
假设 89230 是您的 IIS Express 端口
即使在免费计划中您也可以运行多个端口
The simplest and the coolest way I found was to use (it takes 2 minutes to setup):
https://ngrok.com/
It will work with anything running on localhost. Just signup, run little excutable and whatever you run on localhost gets public URL you can access from anywhere.
This is good for showing stuff to your remote team mates, no fiddling with IIS setup or firewalls. Want to stop access just terminate executable.
assuming that 89230 is your IIS Express port
You can also run multiple ports even on free plan
如果您已尝试 Colonel Panic 的答案,但在 Visual Studio 中不起作用,请尝试以下操作:
附加另一个
<在 IIS Express 配置中绑定/>
最后,您必须以管理员身份运行 Visual Studio
If you have tried Colonel Panic's answer but doesn't work in Visual Studio, try this:
Append another
<binding />
in your IIS Express configFinally, you have to run Visual Studio as Admin
此问题的公认答案是使 IIS Express 与 webmatrix 配合使用的指南。我发现本指南在尝试让它与 VS 2010 一起工作时更有用。
我只是按照步骤 3 和 3 进行操作。 4(以管理员身份运行 IIS Express)并且必须暂时禁用我的防火墙才能使其正常工作。
The accepted answer to this question is a guide for getting IIS Express to work with webmatrix. I found this guide more useful when trying to get it to work with VS 2010.
I just followed steps 3 & 4 (running IIS Express as administrator) and had to temporarily disable my firewall to get it working.
您可以尝试设置端口转发,而不是尝试修改 IIS Express 配置、添加新的 HTTP.sys 规则或以管理员身份运行 Visual Studio。
基本上,您需要将网站运行的 IP:PORT 转发到计算机上的其他空闲端口,但位于外部网络适配器上,而不是本地主机上。
问题是 IIS Express(至少在 Windows 10 上)绑定到
[::1]:port
意味着它侦听 IPv6 端口。你需要考虑到这一点。这是我完成这项工作的方法 - http://programmingflow .com/2017/02/25/iis-express-on-external-ip.html
希望有帮助。
You may try setting up port forwarding instead of trying to modify your IIS Express config, adding new HTTP.sys rules or running Visual Studio as an Admin.
Basically you need to forward the
IP:PORT
your website runs at to some other free port on your machine but on the external network adapter, not localhost.The thing is that IIS Express (at least on Windows 10) binds to
[::1]:port
meaning it listens on IPv6 port. You need to take this into account.Here is how I made this work - http://programmingflow.com/2017/02/25/iis-express-on-external-ip.html
Hope it helps.
我在 Win 8.1 和外部请求中使用 IIS Express 时遇到一些问题。
我按照以下步骤调试外部请求:
它正在工作!
I have some problems using IIS Express in Win 8.1 and external request.
I follow this steps to debug the external request:
It's working!
如果您从管理员运行 Visual Studio,则只需添加
或
进入
If you run Visual Studio from Admin you can add just
<binding protocol="http" bindingInformation="*:8080:*" />
or
<binding protocol="https" bindingInformation="*:8443:*" />
into
我启用了本地 IIS,所以我刚刚为我的调试端口创建了一个重写规则...我认为这比其他方法更好、更酷,因为一旦完成开发就更容易删除...这是重写的外观。 VS
还允许您直接使用本地 IIS 进行开发(然后允许远程连接),但反过来您必须始终以管理员身份运行它......我不喜欢这样。
I had a local IIS enabled so i just created a rewrite rule to my debugging port... I think this is better and cooler than other method because it is easier to remove once am done developing... Here is how the rewrite looks..
VS also allows you to develop using your local IIS directly (which then allows remote connections) but in turn you must always run it as an administrator... I dont like that.
访问外部请求的另一种方法是使用 IIS 而不是 IIS Express。
在我的视觉工作室中,我可以轻松切换。
Another way to access external requests is to use IIS instead of IIS Express.
In my visual studio, I can just switch easily.
我通过使用反向代理方法解决了这个问题。
我安装了 wamp 服务器并使用了 apache Web 服务器的简单反向代理功能。
我添加了一个新端口来监听 Apache Web 服务器 (8081)。然后我添加代理配置作为该端口的虚拟主机。
I solved this problem by using reverse proxy approach.
I installed wamp server and used simple reverse proxy feature of apache web server.
I added a new port to listen to Apache web server (8081). Then I added proxy configuration as virtualhost for that port.
我执行了所有这些步骤,但没有任何帮助。
我需要的只是通过 IIS Express 运行我的应用程序...
希望有帮助。
I did all of these steps and nothing helped me.
And what I need, it's just to run my app via IIS Express...
Hope it helps.
对于我来说,使用它相对简单且直接:
通过在扩展对话框中搜索“Conveyor”来下载 Visual Studio 扩展。然后只需安装即可。
形式:
https://marketplace.visualstudio.com/items?itemName=vs- publisher-1448185.ConveyorbyKeyoti
For me using this, relatively simple, and straight forward:
Download the Visual Studio Extension by searching for 'Conveyor' in the Extensions dialog. Then just install.
form:
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
我无法向本地网络中的其他用户提供 iis 请求,我所要做的就是(除了上述之外)重新启动我的 BT Hub 路由器。
I was unable to serve iis requests to other users in my local network, all I had to do (in addition to the above) was restart my BT Hub router.
这太棒了,甚至用漂亮的域名覆盖了 HTTPS:
http://www.hanselman.com/ blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx
我在其他任何地方都找不到真正很棒的部分,以防万一上述链接消失:
上述实用程序将为您注册 SSL 证书!如果您使用 -UseSelfSigned 选项,则非常简单。
如果您想以困难的方式做事,不明显的部分是您需要告诉 HTTP.SYS 使用什么证书,如下所示:
Certhash 是您可以从 MMC 中的证书属性获取的“指纹”。
This is insanely awesome and even covers HTTPS with pretty domain names:
http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx
The really awesome parts I couldn't find anywhere else on SO in case the above link ever goes away:
The above utility will register the SSL certificate for you! If you use the -UseSelfSigned option, it's super easy.
If you want to do things the hard way, the non-obvious part is you need to tell HTTP.SYS what certificate to use, like this:
Certhash is the "Thumbprint" you can get from the certificate properties in MMC.
我执行了以下操作并能够连接:
1)将 IIS 快速配置绑定从本地主机更改为“*”
绑定协议=“http”绑定信息=“*:8888:*”
2)在防火墙上定义的入站规则以允许特定的入站规则协议类型的端口:tcp
3) 添加以下命令为您的端口添加网络配置:
netsh http 添加 urlacl url=http://*:8888/ user=everyone
I did the following and was able to connect:
1) changed IIS express config binding from local host to '*'
binding protocol="http" bindingInformation="*:8888:*"
2) Defined inbound rule on firewall to allow the particular port for the protocol type: tcp
3) Add the following command to add network configuration for your port:
netsh http add urlacl url=http://*:8888/ user=everyone
在我的 dotnet core 6 项目中帮助我允许远程访问我的 IIS 服务器的是在 [解决方案目录]/Properties/launchSettings.json 中设置项目的“applicationUrl”参数,将值从“http://localhost:5000”更改为” 到“http://0.0.0.0:5000”
但正确设置防火墙以允许访问服务器的 TCP 端口也很重要:在我的例子中,添加了 TCP 端口 5000 的入站规则以允许连接。
What helped me in my dotnet core 6 project to allow remote access to my IIS server is to set up the project's "applicationUrl" parameter in [solution directory]/Properties/launchSettings.json changing the value from "http://localhost:5000" to "http://0.0.0.0:5000"
But it's also important to set up a firewall properly to allow access to server's TCP port: in my case an inbound rule for TCP port 5000 to allow connections was added.
我使用 nginx 进行以下配置,它可以工作。
我被告知 ngrok 也可以工作,但由于木马,它在下载后继续被 Microsoft Defender 删除。
I used nginx with the following configuration and it works
I was informed that ngrok works as well, but it kept on deleted by Microsoft Defender after download, because of Trojan.
[项目属性对话框]
对于使用 VisualStudio 2017 和 NetCore API 项目进行开发:
1) 在 Cmd-Box 中: ipconfig /all 以确定 IP 地址
2a) 在项目属性 -> 输入检索到的 IP 地址调试选项卡
2b) 选择一个端口并将其附加到步骤 2a 中的 IP 地址。
3) 在防火墙中添加允许规则以允许所选端口上的传入 TCP 流量
(我的防火墙触发了一个对话框:“阻止或添加规则到防火墙”)。在这种情况下,添加 will 就可以解决问题。
上述解决方案的缺点:
1) 如果您使用动态 IP 地址,则需要重做上述步骤,以防分配了另一个 IP 地址。
2) 您的服务器现在有一个开放端口,您可能会忘记,但这个开放端口仍然是对不速之客的邀请。
[project properties dialog]
For development using VisualStudio 2017 and a NetCore API-project:
1) In Cmd-Box: ipconfig /all to determine IP-address
2a) Enter the retrieved IP-address in Project properties-> Debug Tab
2b) Select a Port and attach that to the IP-address from step 2a.
3) Add an allow rule in the firewall to allow incoming TCP-traffic on the selected Port
(my firewall triggered with a dialog: "Block or add rule to firewall"). Add will in that case do the trick.
Disadvantage of the solution above:
1) If you use a dynamic IP-address you need to redo the steps above in case another IP-address has been assigned.
2) You server has now an open Port which you might forget, but this open port remains an invitation for unwanted guests.