Simple Injector ASP.NET Core MVC Integration NuGet package
ReviewCoreASPHosting.NET | Best and cheap ASP.NET Core hosting. The following code snippet shows how to use the integration package to apply Simple Injector to your web application’s Startup class.// You'll need to include the following namespaces
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;using SimpleInjector;
using SimpleInjector.Lifestyles;
using SimpleInjector.Integration.AspNetCore;
using SimpleInjector.Integration.AspNetCore.Mvc;public class Startup {
private Container container = new Container();public Startup(IHostingEnvironment env) {
// ASP.NET default stuff here
}// This method gets called by the runtime.
public void ConfigureServices(IServiceCollection services) {
// ASP.NET default stuff here
services.AddMvc();services.AddSingleton<IControllerActivator>(
new SimpleInjectorControllerActivator(container));
services.AddSingleton<IViewComponentActivator>(
...