I am migrating my site from asp.net from 4.5 to 5.0. I used to use System.Web.Mvc to get DependencyResolver.SetResolve to register dependencies. Is there any publication or documentation that can point me to the new version of Microsoft.AspNet.Mvc ?
System.Web.Mvc
DependencyResolver.SetResolve
Microsoft.AspNet.Mvc
http://docs.asp.net/en/latest/fundamentals/dependency-injection.html
This is the official documentation for dependency injection for asp.net 5.
Dependency inclusion is now built into asp.net 5, but you can use other libraries like autofac. By default, it works fine.
In your starup class, you have a method like this
public void ConfigureServices(IServiceCollection services) { //IServiceCollection acts like a container and you //can register your classes like this: services.AddTransient<IEmailSender, AuthMessageSender>(); services.Singleton<ISmsSender, AuthMessageSender>(); services.AddScoped<ICharacterRepository, CharacterRepository>(); }
Here are some service lives and registration options.