Adding New Microsoft Extensions to Legacy WCF and ASMX Web Services
I was asked by several people recently: Can I use dependency injection with my legacy WCF and ASMX web services? Microsoft has some new stuff they released with core–specifically, a new configuration system, caching, and logging providers. Can I use them in my legacy WCF and ASMX web services? The answer to both is yes you can! In fact, I recommend it! To illustrate this, we’ll take a look at taking a sample application that has a WCF service and a ASMX service and we’ll: Add dependency injection using Ninject. Add the new Configuration provider from the new Microsoft.Extensions.Configuration packages. Add caching functionality using Microsoft’s new Microsoft.Extensions.Caching packages. Use the new logging providers from Microsoft.Extensions.Logging packages. Dependency Injection We use Ninject, but you can just as easily use AutoFac or SimpleInjector as they also have packaged integrations for WCF. You can use other containers, bu...