使用VS2015和IIS Express覆盖站点绑定

Kei*_*son 7 iis-express asp.net-core-mvc visual-studio-2015 asp.net-core

我正在使用VS2015 RC在MVC6站点中实现OAuth身份验证.该网站的先前版本需要自定义绑定,我正在努力实现与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"
},
Run Code Online (Sandbox Code Playgroud)

使用dnx命令运行

如果我尝试通过更改applicationhost.config文件(在IIS Express + VS 2015中按照通配符主机名在项目/ .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>
Run Code Online (Sandbox Code Playgroud)

...一个新的站点条目绑定到"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>
Run Code Online (Sandbox Code Playgroud)

该站点现在使用localhost绑定运行.VS愉快地打开dev url并告诉我该服务不可用.

使用IIS Express进行调试

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

小智 3

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

IIS Express + VS 2015 中的通配符主机名

为了使其正常工作,我保留了 localhost 绑定并为 *. 这必须在 ~ProjectFolder~/.vs/config/applicationhost.config 中完成,而不是在 Documents/IISExpress 的旧位置中完成......

在我的例子中,更正后的绑定如下所示:

<bindings>
  <binding protocol="http" bindingInformation="*:4355:localhost" />
  <binding protocol="http" bindingInformation="*:4355:*" />
</bindings>
Run Code Online (Sandbox Code Playgroud)