File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -16,21 +16,25 @@ Install-Package Unity.Microsoft.DependencyInjection
1616- In the ` WebHostBuilder ` add ` UseUnityServiceProvider(...) ` method
1717
1818``` C#
19- public static IWebHost BuildWebHost (string [] args ) =>
20- WebHost .CreateDefaultBuilder (args )
21- .UseUnityServiceProvider () < ---- Add this line
22- .UseStartup <Startup >()
23- .Build ();
19+ public static IHostBuilder CreateHostBuilder (string [] args ) =>
20+ Host .CreateDefaultBuilder (args )
21+ .UseUnityServiceProvider () < ---- Add this line
22+ .ConfigureWebHostDefaults (webBuilder =>
23+ {
24+ webBuilder .UseStartup <Startup >();
25+ });
2426```
2527
2628- In case Unity container configured via application configuration or by convention this container could be used to initialize service provider.
2729
2830``` C#
29- public static IWebHost BuildWebHost (string [] args ) =>
30- WebHost .CreateDefaultBuilder (args )
31- .UseUnityServiceProvider (_container ) < ---- or add this line
32- .UseStartup <Startup >()
33- .Build ();
31+ public static IHostBuilder CreateHostBuilder (string [] args ) =>
32+ Host .CreateDefaultBuilder (args )
33+ .UseUnityServiceProvider (_container ) < ---- Add this line
34+ .ConfigureWebHostDefaults (webBuilder =>
35+ {
36+ webBuilder .UseStartup <Startup >();
37+ });
3438```
3539
3640- Add optional method to your ` Startup ` class
You can’t perform that action at this time.
0 commit comments