如何在IIS Express中启用远程请求?Scott Guthrie写道,这是可能的,但他没有说明如何实现。
当前回答
我发现最简单最酷的方法是使用(设置需要2分钟):
https://ngrok.com/
它将与本地主机上运行的任何东西一起工作。只要注册,运行小可执行程序,不管你在localhost上运行什么,你都可以从任何地方访问公共URL。
这对于向远程团队成员显示内容很有好处,无需摆弄IIS设置或防火墙。要停止访问只需终止可执行文件。
ngrok authtoken xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ngrok http -host-header=localhost 89230
假设89230是您的IIS Express端口
您也可以运行多个端口,甚至在免费计划
其他回答
我无法在我的本地网络中为其他用户提供iis请求,我所要做的(除了上面提到的)就是重新启动我的BT Hub路由器。
在我找到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”应用程序“/”
如果你正在使用Visual Studio,那么按照以下步骤通过ip地址访问IIS-Express:
Get your host IP-Adress: ipconfig in Windows Command Line GoTo $(SolutionDir)\.vs\config\applicationHost.config Find <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> 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
帮助我在dotnet core 6项目中允许远程访问我的IIS服务器的是在[解决方案目录]/Properties/launchSettings中设置项目的“applicationUrl”参数。将Json的值从“http://localhost:5000”更改为“http://0.0.0.0:5000”
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:20845",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MyLittleProject": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"applicationUrl": "http://0.0.0.0:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
但正确设置防火墙以允许访问服务器的TCP端口也很重要:在我的例子中,添加了TCP端口5000的入站规则以允许连接。
推荐文章
- 实体框架核心:在上一个操作完成之前,在此上下文中开始的第二个操作
- 如何为构造函数定制Visual Studio的私有字段生成快捷方式?
- 如何使用JSON确保字符串是有效的JSON。网
- AppSettings从.config文件中获取值
- 通过HttpClient向REST API发布一个空体
- 如何检查IEnumerable是否为空或空?
- 自动化invokerrequired代码模式
- 在c#代码中设置WPF文本框的背景颜色
- 在c#中,什么是单子?
- c#和Java中的泛型有什么不同?和模板在c++ ?
- c#线程安全快速(est)计数器
- 如何将此foreach代码转换为Parallel.ForEach?
- 如何分裂()一个分隔字符串到一个列表<字符串>
- 如何转换列表<字符串>列表<int>?
- c#对象列表,我如何得到一个属性的和