Back in the days of ASP.NET 4.x, each of the framework components - MVC, WebAPI, OWIN, SignalR - had its own dependency resolver and its own way of integrating with the framework. ASP.NET Core brings a consistent dependency injection mechanism with a unified meaning for lifetime or service registration,that is designed to server the needs of the framework and most consumer applications built on it. In this article, we will see a way of defining the service types and the implementation types we want to use based on a JSON file and switch between implementations without changing the code.
In this article we will be looking at ASP .NET Core MVC, more specifically at how to build an API that can be consumed from any type of application, be it web, mobile or desktop. We will build a very simple application that will enable the creation of posts (much like messages) and that will take us through adding the MVC services, creating models, controllers and consuming some data.
The new configuration system provides support for JSON, XML, INI and for in-memory configuration, while also allowing you to create your custom configuration provider. Let’s assume that in our application we want the response messages not to be hardcoded in Startup anymore, but stored in a configuration file so we don’t have to stop, modify or recompile our application every time the messages or the routes change.