b-abpnet01
abp-mvc自定义模块:
nuget引入Volo.Abp.AspNetCore.Mvc
添加自定义module
[DependsOn(typeof(AbpAspNetCoreMvcModule))] public class MyWebStartModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { var services = context.Services; services.AddControllersWithViews(); } public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); } }
修改startup.cs
public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddApplication<MyWebStartModule>(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.InitializeApplication(); } }
可以正常启动
在netcore的控制器中,不需要继承基类可以直接运行的
如下:
namespace MyMVC.Controllers { [Route("api/{controller}")] public class HelloController { [HttpGet("sayhello")] public string SayHello() => "hello net core"; } }
可以获取到

浙公网安备 33010602011771号