效果图:
步骤:
1.创建一个空的asp.net core 空的框架
1.1 引用 Volo.Abp.AspNetCore 包
1.2 修改 startup 文件
namespace helloabp { public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddApplication<Abp1Module>(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.InitializeApplication(); } } }
2.创建一个类库
2.1 引用 Volo.Abp.AspNetCore.Mvc 包
2.2 创建一个 Abp1Module 类库
namespace ClassLibrary1 { [DependsOn(typeof(AbpAspNetCoreMvcModule))] public class Abp1Module:AbpModule { public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseRouting(); app.UseConfiguredEndpoints(options=> { options.MapControllerRoute("app1", "{controller=App1}/{action=Index}/{id?}"); } ); } } }
2.3 创建一个abp控制器(类似以前创建一个mvc控制器 )
namespace ClassLibrary1 { public class App1Controller:AbpController { public IActionResult Index() { return Content(" App1 hello !"); } } }