Skip to content

Latest commit

 

History

History

Bet.AspNet.DependencyInjection.Legacy

Bet.AspNet.DependencyInjection.Legacy

GitHub license Build status NuGet Nuget feedz.io

Note: Pre-release packages are distributed via feedz.io.

The goal of this library is to support gradual migration of the Asp.Net WebForms/ MVC5 or WebApi2 projects to AspNetCore.

Install

    dotnet add package Bet.AspNet.DependencyInjection.Legacy

Usage

Example how to create instance within Asp.Net MVC5, WebApi2 or WebForms

        void Application_Start(object sender, EventArgs e)
        {
            var builder = WebHost.CreateDefaultBuilder<Global>()
                                .ConfigureServices((context, services) =>
                                {
                                    services.AddOptions<AppOptions>()
                                    .Configure<IConfiguration>((options, config) =>
                                    {
                                        config.Bind("AppSettings:AppOptions", options);
                                    });

                                    // register our service here
                                    services.AddTransient<FeedService>();
                                })
                                .Build();

            // Configure DI for Mvc4 and WebApi2 Controllers
            builder.ConfigureMvcDependencyResolver();

            // Configure DI for WebForms
            builder.ConfigureWebFormsResolver();

            // Code that runs on application startup
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
    }