Skip to content

Default Visual Studio project appsettings.json not allowing the configuration of server.urls #1915

Closed
@jmessenger235

Description

@jmessenger235

Default Visual Studio project appsettings.json not allowing the configuration of server.urls

The functional impact of this is that applications that are hosted independently of IIS or tested in that context, require a separate additional configuration file must be added to the default web api project created in Visual Studio

In order to encounter this issue use visual studio 2015 and .net core 1.0.1 tools preview 2 and do the following:
Create a new ASP.NET core web application. (This can either target .net framework 4.6.1 or .net core as I tested both at one point but only verified these steps against the asp.net webapi project that targets the core)
Use the webapi sub-template.
Add: ","server.urls": "http://*:5005"" without the final open and closing double quotes before the final bracket of appsettings.json.
Start the application debugging in the non IIS option for starting and debugging.
Observer that the application binds to port 5000 rather than the specified port 5005

I would expect the default json configuration to allow the setting of server.urls and bind to port 5005.

In actuality, the server.urls parameter in the default appsettings.json is being ignored and the app is starting up listening on port 5000

The problem seems to be in WebHostBuilder.UseStartup. If I add a separate file hosting.json to the program.cs then it loads the parameter correctly and binds to the specified port. The reason I say this is that the same file specified via a configuration builder and added via WebHostBuilder.UseConfiguration properly loads the file and binds to the specified port 5005.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions