我希望能够在 localhost 以外的域以及任何子域上调试我的 ASP.NET MVC 应用程序,换句话说:
http://domain.dev http://*.domain.dev
我尝试过以下方法:
- 修改Hosts文件
- 为 *.domain.dev 添加一条返回 127.0.0.1 的主机记录
- 更改项目属性中的“项目网址”。
但是,没有任何效果。当我开始调试时,我收到一个页面,显示“服务不可用”或“无效 URL”。
我错过了什么?
附:我使用的是 Visual Studio 2013
最佳答案
对于 Visual Studio 2015,上述答案中的步骤适用,但 applicationhost.config 文件位于新位置。在“解决方案”文件夹中遵循路径
\.vs\config
在该文件夹中,您将看到 applicationhost.config 文件
或者,您也可以在解决方案文件夹中搜索 .config 文件并以这种方式找到它。
我个人使用了以下配置:
在我的主机文件中包含以下内容:
127.0.0.1 jam.net
127.0.0.1 www.jam.net
以及我的 applicationhost.config 文件中的以下内容:
<site name="JBN.Site" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Dev\Jam\shoppingcart\src\Web\JBN.Site" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:49707:" />
<binding protocol="http" bindingInformation="*:49707:localhost" />
</bindings>
</site>
记住以管理员身份运行 Visual Studio 2015 实例!如果您不想每次我推荐时都这样做:
How to Run Visual Studio as Administrator by default
我希望这对某人有帮助,我在尝试升级到 Visual Studio 2015 时遇到了问题,并意识到我的所有配置都没有被保留。
关于asp.net-mvc - 更改项目 URL Visual Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20978686/