File tree Expand file tree Collapse file tree 4 files changed +27
-23
lines changed
AbpCompanyName.AbpProjectName.Web.Host/Startup
AbpCompanyName.AbpProjectName.Web.Mvc/Startup Expand file tree Collapse file tree 4 files changed +27
-23
lines changed Original file line number Diff line number Diff line change 1- using Microsoft . AspNetCore ;
1+ using Abp . AspNetCore . Dependency ;
2+ using Abp . Dependency ;
23using Microsoft . AspNetCore . Hosting ;
3- using Microsoft . Extensions . Configuration ;
4- using System . IO ;
4+ using Microsoft . Extensions . Hosting ;
55
66namespace AbpCompanyName . AbpProjectName . Web . Host . Startup
77{
88 public class Program
99 {
1010 public static void Main ( string [ ] args )
1111 {
12- BuildWebHost ( args ) . Run ( ) ;
12+ CreateHostBuilder ( args ) . Build ( ) . Run ( ) ;
1313 }
1414
15- public static IWebHost BuildWebHost ( string [ ] args )
16- {
17- return WebHost . CreateDefaultBuilder ( args )
18- . UseStartup < Startup > ( )
19- . Build ( ) ;
20- }
15+ internal static IHostBuilder CreateHostBuilder ( string [ ] args ) =>
16+ Microsoft . Extensions . Hosting . Host . CreateDefaultBuilder ( args )
17+ . ConfigureWebHostDefaults ( webBuilder =>
18+ {
19+ webBuilder . UseStartup < Startup > ( ) ;
20+ } )
21+ . UseCastleWindsor ( IocManager . Instance . IocContainer ) ;
2122 }
2223}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public Startup(IWebHostEnvironment env)
3838 _appConfiguration = env . GetAppConfiguration ( ) ;
3939 }
4040
41- public IServiceProvider ConfigureServices ( IServiceCollection services )
41+ public void ConfigureServices ( IServiceCollection services )
4242 {
4343 //MVC
4444 services . AddControllersWithViews (
@@ -78,7 +78,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
7878 ConfigureSwagger ( services ) ;
7979
8080 // Configure Abp and Dependency Injection
81- return services . AddAbp < AbpProjectNameWebHostModule > (
81+ services . AddAbpWithoutCreatingServiceProvider < AbpProjectNameWebHostModule > (
8282 // Configure Log4Net logging
8383 options => options . IocManager . IocContainer . AddFacility < LoggingFacility > (
8484 f => f . UseAbpLog4Net ( ) . WithConfig ( _hostingEnvironment . IsDevelopment ( )
@@ -89,7 +89,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
8989 ) ;
9090 }
9191
92- public void Configure ( IApplicationBuilder app , ILoggerFactory loggerFactory )
92+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env , ILoggerFactory loggerFactory )
9393 {
9494 app . UseAbp ( options => { options . UseAbpRequestLocalization = false ; } ) ; // Initializes ABP framework.
9595
Original file line number Diff line number Diff line change 1- using Microsoft . AspNetCore ;
1+ using Abp . AspNetCore . Dependency ;
2+ using Abp . Dependency ;
23using Microsoft . AspNetCore . Hosting ;
4+ using Microsoft . Extensions . Hosting ;
35
46namespace AbpCompanyName . AbpProjectName . Web . Startup
57{
68 public class Program
79 {
810 public static void Main ( string [ ] args )
911 {
10- BuildWebHost ( args ) . Run ( ) ;
12+ CreateHostBuilder ( args ) . Build ( ) . Run ( ) ;
1113 }
1214
13- public static IWebHost BuildWebHost ( string [ ] args )
14- {
15- return WebHost . CreateDefaultBuilder ( args )
16- . UseStartup < Startup > ( )
17- . Build ( ) ;
18- }
15+ internal static IHostBuilder CreateHostBuilder ( string [ ] args ) =>
16+ Host . CreateDefaultBuilder ( args )
17+ . ConfigureWebHostDefaults ( webBuilder =>
18+ {
19+ webBuilder . UseStartup < Startup > ( ) ;
20+ } )
21+ . UseCastleWindsor ( IocManager . Instance . IocContainer ) ;
1922 }
2023}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public Startup(IWebHostEnvironment env)
3333 _appConfiguration = env . GetAppConfiguration ( ) ;
3434 }
3535
36- public IServiceProvider ConfigureServices ( IServiceCollection services )
36+ public void ConfigureServices ( IServiceCollection services )
3737 {
3838 // MVC
3939 services . AddControllersWithViews (
@@ -60,7 +60,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
6060 services . AddSignalR ( ) ;
6161
6262 // Configure Abp and Dependency Injection
63- return services . AddAbp < AbpProjectNameWebMvcModule > (
63+ services . AddAbpWithoutCreatingServiceProvider < AbpProjectNameWebMvcModule > (
6464 // Configure Log4Net logging
6565 options => options . IocManager . IocContainer . AddFacility < LoggingFacility > (
6666 f => f . UseAbpLog4Net ( ) . WithConfig (
You can’t perform that action at this time.
0 commit comments