asp.net-mvc - 更改项目 URL Visual Studio

标签 asp.net-mvc visual-studio-2013

我希望能够在 localhost 以外的域以及任何子域上调试我的 ASP.NET MVC 应用程序,换句话说:

http://domain.dev http://*.domain.dev

我尝试过以下方法:

  1. 修改Hosts文件
  2. 为 *.domain.dev 添加一条返回 127.0.0.1 的主机记录
  3. 更改项目属性中的“项目网址”。

但是,没有任何效果。当我开始调试时,我收到一个页面,显示“服务不可用”或“无效 URL”。

我错过了什么?

附:我使用的是 Visual Studio 2013

最佳答案

对于 Visual Studio 2015,上述答案中的步骤适用,但 applicationhost.config 文件位于新位置。在“解决方案”文件夹中遵循路径

\.vs\config

在该文件夹中,您将看到 applicationhost.config 文件

或者,您也可以在解决方案文件夹中搜索 .config 文件并以这种方式找到它。

我个人使用了以下配置:

enter image description here

在我的主机文件中包含以下内容:

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/

相关文章:

c# - 获取常规 ConfigurationErrorsException

c# - Visio 2013 - 让 C# 作为宏工作?

JavaScript 文字插入值? (字 rune 字中的字符太多)

asp.net-mvc - Entity Framework - 无法创建类型为 x 的常量值。在此上下文中仅支持原始类型。

android - 从 VS2013 C++ 代码创建 APK 文件

c++ - C++ 编译器之间的巨大性能差异

.net - SQL Server 数据库项目在 VS 2013 中不兼容

jquery - 在 asp.net 中下载文件后完成事件触发

html - 如何从添加到我的元素的字体中使用@font-face?

jquery - 将循环中的项目 ID 传递给 Jquery