通过局域网连接到 Visual Studio 调试 IIS Express 服务器

2023-12-05

我有一个在 VS2012 中开发的测试 ASP.NET MVC3 应用程序。当我开始调试时,通过请求从主机访问应用程序http://localhost:<portnumber>。但是,如果我尝试通过 Intranet 中的远程计算机访问相同的应用程序http://<ip>:<portnumber> I get HTTP error 400: Bad request. Invalid Host Name.只要它在 IIS Express 上运行,任何服务器配置都是不可访问的。

有什么方法可以解决这个问题吗?


Update

我制作了一个视频来更好地描述这个过程,https://youtu.be/5ZqDuvTqQVs

如果您使用的是 Visual Studio 2013 或更高版本,请确保以管理员身份运行它才能正常工作。


Open the %USERPROFILE%\My Documents\IISExpress\config\applicationhost.config (in VS2015 it may be $(solutionDir)\.vs\config\applicationhost.config) file. Inside you should see something like this:
<site name="WebSite1" id="1" serverAutoStart="true">
    <application path="/">
        <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:8080:localhost" />
    </bindings>
</site>

改变bindingInformation=":8080:localhost" to bindingInformation="*:8080:*"(端口号(在我的例子中为 8080)会有所不同。)

Note:如果它不起作用尝试bindingInformation="*:8080:星号可以移除。

然后确保您的防火墙允许该端口上的传入连接。您可能需要重新启动系统或至少重新启动 Visual Studio 才能让 IISExpress 重新加载配置文件。

如果这不起作用,请看一下这个答案:https://stackoverflow.com/a/5186680/985284

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

通过局域网连接到 Visual Studio 调试 IIS Express 服务器 的相关文章

随机推荐