Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override site binding using VS2015 and IIS Express

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?

like image 301
Keith Davidson Avatar asked Jun 13 '15 16:06

Keith Davidson


People also ask

How do I change IIS Express settings in Visual Studio?

Configure IIS express on visual studioSelect the web application project and open properties -> select the web tab -> under server's select IIS express-> Specify the project URL. Now open the project folder and . vs folder (Hidden) -> Config -> applicationhost.

How do I enable IIS Express in Visual Studio 2015?

go to control panel => programs and features => turn windows features on or of => tick 'internet information services' and click ok.


1 Answers

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>
like image 65
Byron Avatar answered Oct 23 '22 05:10

Byron