简体   繁体   English

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

[英]Override site binding using VS2015 and IIS Express

I'm implementing OAuth authentication in a MVC6 site using VS2015 RC. 我正在使用VS2015 RC在MVC6站点中实现OAuth身份验证。 The previous incarnation of the site required a custom binding and I'm trying to achieve the same with VS2015. 该网站的先前版本需要自定义绑定,我正在努力实现与VS2015相同。 Debugging with IIS Express, however, is proving difficult. 但是,使用IIS Express进行调试很困难。

If I amend the dnx "web" command to use an alternate url, all works as expected: 如果我修改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"
},

使用dnx命令运行

If I try and do the same thing with IIS Express by changing the applicationhost.config file (within the project/.vs/config folder as per Wildcard hostname in IIS Express + VS 2015 )... 如果我尝试通过更改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>

...a new site entry is with a binding to "localhost". ...一个新的站点条目绑定到“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>

The site is now running using the localhost binding. 该站点现在使用localhost绑定运行。 VS happily opens the dev url and tells me that the service is unavailable. VS愉快地打开dev url并告诉我该服务不可用。

使用IIS Express进行调试

How can I instruct VS2015 to use the existing site and binding when debugging with IIS Express? 在使用IIS Express进行调试时,如何指示VS2015使用现有站点和绑定?

I used the instructions as defined here with a slight modification: 我使用了这里定义的说明稍作修改:

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

In order to make it work I left the localhost binding and added an additional binding for *. 为了使它工作,我离开了localhost绑定并为*添加了一个额外的绑定。 This must be done in the ~ProjectFolder~/.vs/config/applicationhost.config and not in the old location of Documents/IISExpress..... 这必须在~ProjectFolder~ / .vs / config / applicationhost.config中完成,而不是在Documents / IISExpress的旧位置.....

The corrected binding looks like this in my case: 在我的情况下,更正的绑定看起来像这样:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM