如何在IIS Express中启用远程请求?Scott Guthrie写道,这是可能的,但他没有说明如何实现。
当前回答
如果你正在使用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
其他回答
在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)
如果你尝试过Panic上校的答案,但在Visual Studio中不起作用,试试这个:
在IIS Express配置中附加另一个<binding />
<bindings>
<binding protocol="http" bindingInformation="*:8080:localhost" />
<binding protocol="http" bindingInformation="*:8080:hostname" />
</bindings>
最后,你必须以管理员的身份运行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
希望能有所帮助。
这个问题的公认答案是如何让IIS Express使用webmatrix的指南。我发现这个指南在使用VS 2010时更有用。
我只是按照步骤3和4(以管理员身份运行IIS Express),并且不得不暂时禁用我的防火墙才能让它工作。
这是我用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不是以管理员身份运行,则可能会失败。现在一切都正常了。
推荐文章
- ASP是什么?NET Identity的IUserSecurityStampStore<TUser>接口?
- net HttpClient。如何POST字符串值?
- 我如何使一个方法的返回类型泛型?
- 何时处理CancellationTokenSource?
- ASP。网网络。config: configSource vs.文件属性
- 如何获取正在执行的程序集版本?
- AutoMapper vs valueinjector
- 为什么控制台不。Writeline,控制台。在Visual Studio Express中编写工作?
- 什么是.NET程序集?
- 字符串不能识别为有效的日期时间“格式dd/MM/yyyy”
- 函数应该返回空对象还是空对象?
- 如何转换日期时间?将日期时间
- 如何在c#中连接列表?
- 在c#中引用类型变量的“ref”的用途是什么?
- 防止在ASP中缓存。NET MVC中使用属性的特定操作