iis-express - 使用 VS2015 和 IIS Express 覆盖站点绑定(bind)

标签 iis-express asp.net-core visual-studio-2015 asp.net-core-mvc

我正在使用 VS2015 RC 在 MVC6 站点中实现 OAuth 身份验证。该站点的前一个化身需要自定义绑定(bind),我正在尝试使用 VS2015 实现相同的目标。然而,使用 IIS Express 进行调试被证明是困难的。

如果我将 dnx“web”命令修改为使用备用 url,一切都会按预期工作:

"commands": {
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://www.devurl.co.uk:31122",
    "gen": "Microsoft.Framework.CodeGeneration",
    "ef":  "EntityFramework.Commands"
},

Running using dnx command

如果我尝试通过更改 applicationhost.config 文件(根据 Wildcard hostname in IIS Express + VS 2015 在 project/.vs/config 文件夹中)对 IIS Express 执行相同的操作...
<sites>
    <site name="WebApp1" id="1">
        <!-- removed for brevity -->
        <bindings>
            <binding protocol="http" bindingInformation="*:31122:www.devurl.co.uk" />
        </bindings>
    </site>
        <!-- removed for brevity -->
</sites>

...一个新的站点条目绑定(bind)到“localhost”。
<sites>
    <site name="WebApp1" id="1">
        <!-- removed for brevity -->
        <bindings>
            <binding protocol="http" bindingInformation="*:31122:www.devurl.co.uk" />
        </bindings>
    </site>
    <site name="WebApp1(1)" id="2">
        <!-- removed for brevity -->
        <bindings>
            <binding protocol="http" bindingInformation="*:31122:localhost" />
        </bindings>
    </site>
    <!-- removed for brevity -->
</sites>

该站点现在使用 localhost 绑定(bind)运行。 VS 愉快的打开 dev url 告诉我服务不可用。

Debugging with IIS Express

使用 IIS Express 进行调试时,如何指示 VS2015 使用现有站点和绑定(bind)?

最佳答案

我使用了此处定义的说明并稍作修改:

Wildcard hostname in IIS Express + VS 2015

为了使它工作,我离开了 localhost 绑定(bind)并为 *.这必须在 ~ProjectFolder~/.vs/config/applicationhost.config 中完成,而不是在 Documents/IISExpress 的旧位置......

在我的情况下,更正的绑定(bind)看起来像这样:

<bindings>
  <binding protocol="http" bindingInformation="*:4355:localhost" />
  <binding protocol="http" bindingInformation="*:4355:*" />
</bindings>

关于iis-express - 使用 VS2015 和 IIS Express 覆盖站点绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30820756/

相关文章:

visual-studio-2010 - IIS Express 7.5 拒绝从 VS 2K10 Ultimate 启动

wcf - VS2013无法在解决方案中添加WCF服务引用

Visual Studio 2015 中未检测到 Android 手机

visual-studio-2013 - 没有为 TypeScript 编译器提供编译文件,因此它将跳过编译

visual-studio - VS 2012 IIS Express 8 - 无法启动 IIS Express Web 服务器

asp.net - 内部服务器错误 500.24

asp.net-core - 如何通过依赖注入(inject)将 IOptions 传递给另一个项目

asp.net-core - 如何在 .Net Core Blazor 应用程序中创建带有可折叠子菜单的 NavMenu

.NET Core 2.2 CORS 不允许请求

sql-server - 错误 56。无法从注册表中指定的位置加载 SQLUserInstance.dll