Introduction

This document describes ASP.NET Core integration for ASP.NET Boilerplate framework.

ASP.NET Core integration is implemented in Abp.AspNetCore nuget package

Startup Template

TODO: Still working to create a simple startup template.

Configuration

Startup Class

To integrate ABP to ASP.NET Core, we should make some changes in the Startup class as shown below:

public class Startup
{
    public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        //...
    
        services.AddMvc(mvcOptions =>
        {
            //Add ABP infrastructure (filters... etc.) to MVC
            mvcOptions.AddAbp();
            //...
        });

        //Configure Abp and Dependency Injection. Should be called last.
        return services.AddAbp();
    }

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        //Initializes ABP framework and all modules. Should be called first.
        app.UseAbp(); 
        
        //...
    }
}

Module Configuration

TODO

Controllers

Controllers can be any type of classes in ASP.NET Core. It's not restricted to classes derived from Controller class. By default, a class ends with Controller (like ProductController) is considered as MVC Controller. You can also add MVC's [Controller] attribute to any class to make it a controller. See ASP.NET Core documentation for more.

If you will use web layer classes (like HttpContext) or return a view, it's better to inherit from AbpController (which is derived from MVC's Controller) class. But if you are creating an API controller just works with objects, you can consider to create a POCO controller class or you can use your application services as controller as described below.

Application Services as Controllers

ASP.NET Boilerplate provides infrastructure to create application services. If you want to expose your application services to remote clients as controllers (as previously done using dynamic web api), you can easily do it by a simple configuration in PreInitialize method of your module:

Configuration.Modules.AbpAspNetCore().CreateControllersForAppServices(typeof(MyApplicationModule).Assembly);

CreateControllersForAppServices method gets an assembly and converts all application services to MVC controllers in that assembly. You can use RemoteService attribute to enable/disable it for method or class level.

Note: Previously, dynamic web api system was requiring to create interfaces for application services. But this is not required for ASP.NET Core integration.

Filters

ABP defines some pre-built filters for AspNet Core. All of them are added to all actions of all controllers by default.

Authorization Filter

AbpAuthorizationFilter is used to integrate to authorization system and feature system.

Audit Action Filter

AbpAuditActionFilter is used to integrate to audit logging system. It logs all requests to all actions by default (if auditing is not disabled).

You can control audit logging using Audited and DisableAuditing attributes for actions and controllers.

Validation Action Filter

AbpValidationActionFilter is used to integrate to validation system and automatically validates all inputs of all actions. In addition to ABP's built-in validation & normalization, it also checks MVC's Model.IsValid property and throws validation exception if action inputs have any invalid value.

You can control validation using EnableValidation and DisableValidation attributes for actions and controllers.

Unit of Work Action Filter

AbpUowActionFilter is used to integrate to Unit of Work system. It automatically begins a new unit of work before an action execution and completes unit of work after action exucition (if no exception is thrown).

You can use UnitOfWork attribute to control behaviour of UOW for an action.

Exception Filter

AbpExceptionFilter is used to handle exceptions thrown from controller actions. It handles and logs exceptions and returns wrapped response to the client.

Result Filter

AbpResultFilter is used to wrap result action if action is successfully executed.

Client Proxies

TODO

....