Override site binding using VS2015 and IIS Express

2.5k views Asked by At

I'm implementing OAuth authentication in a MVC6 site using VS2015 RC. The previous incarnation of the site required a custom binding and I'm trying to achieve the same with VS2015. Debugging with IIS Express, however, is proving difficult.

If I amend the dnx "web" command to use an alternate url, all works as expected:

"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

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)...

<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".

<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. VS happily opens the dev url and tells me that the service is unavailable.

Debugging with IIS Express

How can I instruct VS2015 to use the existing site and binding when debugging with IIS Express?

1

There are 1 answers

0
Byron On

I used the instructions as defined here with a slight modification:

Wildcard hostname in IIS Express + VS 2015

In order to make it work I left the localhost binding and added an additional binding for *. This must be done in the ~ProjectFolder~/.vs/config/applicationhost.config and not in the old location of Documents/IISExpress.....

The corrected binding looks like this in my case:

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