Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Have you broken Kestrel configuration? #1442 #2495

Closed
Mattacks opened this issue Apr 16, 2018 · 10 comments
Closed

Have you broken Kestrel configuration? #1442 #2495

Mattacks opened this issue Apr 16, 2018 · 10 comments

Comments

@Mattacks
Copy link

Issue Title

Have you broken Kestrel configuration?

General

In .Net Core 1.0 in Main you used to be able to '.Build()' on the builder to get the configuration resolved, in order to be able to use configuration in .UseKestrel(...)

Unless I am mistaken, that is now not possible in 2.1 - one can only use constants or read from files by hand.
Am I mistaken?

cheers

Matt

(upon advice, copied from here)

@Tratcher
Copy link
Member

2.0 added lots of other ways to configure Kestrel, but the original ways mostly still worked. 2.1 has added even more ways...

There is one common confusion in 2.x where people try to use ConfigreAppConfiguration in Main to configure the Urls key, but you need to Configure the host instead.

Please show us how you are trying to configure it.

@Mattacks
Copy link
Author

In Program.cs:

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .ConfigureAppConfiguration(ConfigConfiguration)
                .ConfigureLogging(ConfigureLogger)
                .Build();

Where ConfigConfiguration does a few config.AddJsonFile...
I want to be able to do a .UseKestrel(...) and supply settings to kestrel read via the configuration system.
In 2.0 you used to be able to do it like this.

@Tratcher
Copy link
Member

The sample you linked to should work. Why are you using ConfigureAppConfiguration instead of UseConfiguration? It's the Urls parameter you're trying to set, correct?

Or you could try the new Endpoints config. #2186

@Mattacks
Copy link
Author

  1. Because I want to use multiple configuration files. Can't remember where I got the original pattern from, but you can also it being used here. And it is also the method used in the Sample startup.cs found when I follow your Implement configuration support #2186 link
  2. No. I'm trying to set limits such as MaxRequestBufferSize

@Tratcher
Copy link
Member

Tratcher commented Apr 16, 2018

? MaxRequestBufferSize has never been mapped from config, in 1.x or 2.x. Or were you calling Bind?

@Mattacks
Copy link
Author

No it has not been mapped from config. That is why we put it in our own config and set it in Main as per this example.
That is why I want to be able to read our own config before the Kestrel initialisation and pass those settings in.

@halter73
Copy link
Member

That is why I want to be able to read our own config before the Kestrel initialisation and pass those settings in.

Does the code from SO answer you linked to no longer work? 2.1 should be source compatible with 2.0 with few exceptions.

@Mattacks
Copy link
Author

Mattacks commented Apr 17, 2018

It does not work any more.

Previously .Build() returned an IConfigurationRoot
Now .Build() returns an IWebHost
In addition, you used to be able to call .Build() twice. Now if you do that you get an InvalidOperationException.

@Tratcher
Copy link
Member

There are two builders in that example, a config builder and a web host builder. Make sure you're calling Build on the right one.

I'm putting this issue on hold until you post a complete code sample and error stack traces as relevant. None of the code samples or errors you've provided have been complete or matched the complaints you've made.

@Mattacks
Copy link
Author

There are two builders in that example, a config builder and a web host builder
That was the missing link. Did not realise. Apologies for wasting your time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants