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 ;
2
3
using Microsoft . AspNetCore . Hosting ;
3
- using Microsoft . Extensions . Configuration ;
4
- using System . IO ;
4
+ using Microsoft . Extensions . Hosting ;
5
5
6
6
namespace AbpCompanyName . AbpProjectName . Web . Host . Startup
7
7
{
8
8
public class Program
9
9
{
10
10
public static void Main ( string [ ] args )
11
11
{
12
- BuildWebHost ( args ) . Run ( ) ;
12
+ CreateHostBuilder ( args ) . Build ( ) . Run ( ) ;
13
13
}
14
14
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 ) ;
21
22
}
22
23
}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public Startup(IWebHostEnvironment env)
38
38
_appConfiguration = env . GetAppConfiguration ( ) ;
39
39
}
40
40
41
- public IServiceProvider ConfigureServices ( IServiceCollection services )
41
+ public void ConfigureServices ( IServiceCollection services )
42
42
{
43
43
//MVC
44
44
services . AddControllersWithViews (
@@ -78,7 +78,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
78
78
ConfigureSwagger ( services ) ;
79
79
80
80
// Configure Abp and Dependency Injection
81
- return services . AddAbp < AbpProjectNameWebHostModule > (
81
+ services . AddAbpWithoutCreatingServiceProvider < AbpProjectNameWebHostModule > (
82
82
// Configure Log4Net logging
83
83
options => options . IocManager . IocContainer . AddFacility < LoggingFacility > (
84
84
f => f . UseAbpLog4Net ( ) . WithConfig ( _hostingEnvironment . IsDevelopment ( )
@@ -89,7 +89,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
89
89
) ;
90
90
}
91
91
92
- public void Configure ( IApplicationBuilder app , ILoggerFactory loggerFactory )
92
+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env , ILoggerFactory loggerFactory )
93
93
{
94
94
app . UseAbp ( options => { options . UseAbpRequestLocalization = false ; } ) ; // Initializes ABP framework.
95
95
Original file line number Diff line number Diff line change 1
- using Microsoft . AspNetCore ;
1
+ using Abp . AspNetCore . Dependency ;
2
+ using Abp . Dependency ;
2
3
using Microsoft . AspNetCore . Hosting ;
4
+ using Microsoft . Extensions . Hosting ;
3
5
4
6
namespace AbpCompanyName . AbpProjectName . Web . Startup
5
7
{
6
8
public class Program
7
9
{
8
10
public static void Main ( string [ ] args )
9
11
{
10
- BuildWebHost ( args ) . Run ( ) ;
12
+ CreateHostBuilder ( args ) . Build ( ) . Run ( ) ;
11
13
}
12
14
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 ) ;
19
22
}
20
23
}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public Startup(IWebHostEnvironment env)
33
33
_appConfiguration = env . GetAppConfiguration ( ) ;
34
34
}
35
35
36
- public IServiceProvider ConfigureServices ( IServiceCollection services )
36
+ public void ConfigureServices ( IServiceCollection services )
37
37
{
38
38
// MVC
39
39
services . AddControllersWithViews (
@@ -60,7 +60,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
60
60
services . AddSignalR ( ) ;
61
61
62
62
// Configure Abp and Dependency Injection
63
- return services . AddAbp < AbpProjectNameWebMvcModule > (
63
+ services . AddAbpWithoutCreatingServiceProvider < AbpProjectNameWebMvcModule > (
64
64
// Configure Log4Net logging
65
65
options => options . IocManager . IocContainer . AddFacility < LoggingFacility > (
66
66
f => f . UseAbpLog4Net ( ) . WithConfig (
You can’t perform that action at this time.
0 commit comments