All docs
V21.2
21.2 (EAP/Beta)
21.1
The page you are viewing does not exist in version 21.1. This link will take you to the root page.
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
You are viewing help content for pre-release software. This document and the features it describes are subject to change.

Backend Web API Service (CTP)

  • 3 minutes to read

Important

We do not recommend that you use the Backend Web API Service in production code. We made this service available to gather feedback from anyone who considers it for future use.

Overview

You can utilize the Backend Web API Service (Web API) to reuse existing data models and Security System settings (users, roles, and permissions) stored in an XAF application database (backend) in the non-XAF .NET application.

The Web API creates URLs (endpoints) that allow you to execute CRUD operations with business objects. It uses ASP.NET Core OData 8.0 (OData v4.0) to support paging, filters, and other OData options. The current Web API version supports the XPO ORM.

The Web API utilizes Swagger to display and test endpoints. You can also test them with other platforms (for example, Postman).

How to Use

You can add the Web API to an existing XAF ASP.NET Core Blazor application or create a new one with this service as described in the following topic: Create a New Application with the Web API. The ASP.NET Core Blazor Application template includes the Web API in DevExpress components v21.2 or later.

To use the Web API Service, install the DevExpress.ExpressApp.WebApi NuGet package to the MySolution.Blazor.Server project. See the following topic for details: Install DevExpress Controls Using NuGet Packages.

Call the services.AddXafWebApi method to create endpoints for business objects. The following code creates endpoints for the ApplicationUser and Contact business objects:

File: MySolution.Blazor.Server\Startup.cs

using MySolution.Module.BusinessObjects;
// ...
services.AddXafWebApi(options => {
    options.BusinessObject<ApplicationUser>();
    options.BusinessObject<Contact>();
});
// ...

Add /swagger to the application address (for example, https://localhost:44318/swagger ) and press Enter to display a page with available endpoints. Refer to the following link for more information on the page’s UI: Swagger UI.

XAF Web API

Authentication Options

The Web API supports all standard ASP.NET Core authentication techniques that you can specify in the MySolution.Blazor.Server\Startup.cs file. See the following topic for more information: Authentication.

The following topic describes how to enable the OAuth2 authentication in a new application with the Web API: Enable the OAuth2 Authentication in a New Application with the Web API.

Performance Considerations

You can disable logging to improve the Web API performance. To do this, set the LogLevel.DevExpress.ExpressApp option to None.

File: MySolution.Blazor.Server\appsettings.json (MySolution.Blazor.Server\appsettings.Development.json for debugging)

// ...
"LogLevel": {
    "Default": "Information",
    "Microsoft": "Warning",
    "Microsoft.Hosting.Lifetime": "Information",
    "DevExpress.ExpressApp": "None"
}
// ...

Use logging options other than None (for example, the DevExpress.ExpressApp = Debug) only for debugging purposes because logging reduces performance.