通过局域网连接到 Visual Studio 调试 IIS Express 服务器 [英] Connecting to Visual Studio debugging IIS Express server over the lan

查看:32
本文介绍了通过局域网连接到 Visual Studio 调试 IIS Express 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 VS2012 中开发的测试 ASP.NET MVC3 应用程序.当我开始调试时,通过对 http://localhost: 的请求从主机访问应用程序.但是,如果我尝试通过 http://<ip>:<portnumber> 从 Intranet 中的远程机器访问相同的应用程序,我会收到 HTTP 错误 400:错误的请求.主机名无效.只要它在 IIS Express 上运行,任何服务器配置都无法访问.

I have a test ASP.NET MVC3 application developed in VS2012. When I start debugging the app is accessed from the host machine via the request to http://localhost:<portnumber>. But if I try to access the same application from the remote machine in the intranet via the http://<ip>:<portnumber> I get HTTP error 400: Bad request. Invalid Host Name. As far as it runs on IIS Express any server configuration is inaccessible.

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

Are there any ways of solving this?

推荐答案

更新

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

I made a video that better describes the process, https://youtu.be/5ZqDuvTqQVs

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

If you are using Visual Studio 2013 or above, make sure you run it as an administrator for this to work.

<小时>打开%USERPROFILE%My DocumentsIISExpressconfigapplicationhost.config(在VS2015中可能是$(solutionDir).vsconfigapplicationhost.config)文件.在里面你应该看到这样的东西:


Open the %USERPROFILE%My DocumentsIISExpressconfigapplicationhost.config (in VS2015 it may be $(solutionDir).vsconfigapplicationhost.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" 更改为 bindingInformation="*:8080:*"(端口号,在我的情况下为 8080,会有所不同.)

Change the bindingInformation=":8080:localhost" to bindingInformation="*:8080:*" (the port number, 8080 in my case, will differ.)

注意:如果它不起作用,请尝试使用 bindingInformation="*:8080: 可以删除星号.

Note: If it does not work try with bindingInformation="*:8080: the asterix can be removed.

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

Then make sure your firewall is allowing incoming connections on that port. You may need to restart the system or at least Visual Studio to get IISExpress to reload the config file.

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

If this doesn't work, take a look at this answer: https://stackoverflow.com/a/5186680/985284

这篇关于通过局域网连接到 Visual Studio 调试 IIS Express 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆