首先引用volo.abp.core和volo.abp.asp.netcore.mvc,同样需要开启包括预发行版
创建AppModule继承AbpMoudle,
然后在类上加上特性 [DependsOn(typeof(AbpAspNetCoreMvcModule))],
此时就可以覆写OnApplicationInitialization,在此处可以配置管道
[DependsOn(typeof(AbpAspNetCoreMvcModule))]
public class AppModule:AbpModule
{
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env=context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseRouting();
app.UseConfiguredEndpoints();
}
}
然后在program类里注册模块
builder.Services.AddApplication<AppModule>();
app.InitializeApplication();
然后新建控制器就可以继承 AbpController
[Route("api/[controller]")]
[ApiController]
public class HomeController : AbpController
{
[HttpGet(Name = "index")]
public IActionResult Index()
{
return Content("Index");
}
}
此时最基础的abp就引用进来了