Injecting Action Method Values from Configuration in ASP.NET Core
Introduction ASP.NET Core offers some mechanisms by which it can automatically "inject", or set, values to action method parameters. Normally these come from the query string, the form, the payload, headers, or the Dependency Injection (DI), but the mechanism is extensible, and here we will see a way to inject values from the configuration. We will build: A binding source A model binder provider A model binder An extension method to ease the registration of the model binder provider An "injection" attribute to trigger the injection Model binding in ASP.NET Core is a complex topic and we won't cover it in depth, just what is needed to get this done with a custom model binder . What I'm going to present could probably be done with either a custom value provider or a custom model binder (as in this post), as they are related topics: the former is used to get values from sources and the latter to get them into .NET classes. I will go with model binding for now,...