ABP is a modular framework and it requires astartup (root) module class derived fromAbpModule:
using Microsoft.AspNetCore.Builder;using Microsoft.Extensions.Hosting;using Volo.Abp;using Volo.Abp.AspNetCore.Mvc;using Volo.Abp.Modularity;namespace BasicAspNetCoreApplication{ [DependsOn(typeof(AbpAspNetCoreMvcModule))] public class AppModule : AbpModule { public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); // Configure the HTTP request pipeline. if (env.IsDevelopment()) { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseConfiguredEndpoints(); } }}
AppModule is a good name for the startup module for an application.
ABP packages define module classes and a module can depend on another. In the code above, theAppModule depends on theAbpAspNetCoreMvcModule (defined by theVolo.Abp.AspNetCore.Mvc package). It's common to add aDependsOn attribute after installing a new ABP NuGet package.
Instead of the Startup class, we are configuring an ASP.NET Core pipeline in this module class.
The Program Class
Next step is to modify the Program class to integrate to the ABP module system:
builder.AddApplicationAsync<AppModule>(); adds all services defined in all modules starting from theAppModule.
app.InitializeApplicationAsync() initializes and starts the application.
Run the Application!
That's all! Run the application, it will just work as expected.
Using Autofac as the Dependency Injection Framework
While ASP.NET Core's Dependency Injection (DI) system is fine for basic requirements,Autofac provides advanced features like Property Injection and Method Interception which are required by ABP to perform advanced application framework features.
Replacing ASP.NET Core's DI system by Autofac and integrating to ABP is pretty easy.