Skip to main content
All docs
V24.1
.NET 6.0+
  • The page you are viewing does not exist in the .NET Framework 4.5.2+ platform documentation. This link will take you to the parent topic of the current section.

WebApiStartupExtensions.AddXafWebApi(IServiceCollection, IConfiguration, Action<WebApiOptions>) Method

An extension method that adds Web API services to the service collection.

Namespace: DevExpress.ExpressApp.WebApi.Services

Assembly: DevExpress.ExpressApp.WebApi.v24.1.dll

NuGet Package: DevExpress.ExpressApp.WebApi

Declaration

public static XafWebApiBuilder AddXafWebApi(
    this IServiceCollection services,
    IConfiguration configuration,
    Action<WebApiOptions> configureOptions
)

Parameters

Name Type Description
services IServiceCollection

A service collection for which the AddXafWebApi extension method is called.

configuration IConfiguration

The application configuration.

configureOptions Action<WebApiOptions>

An Action delegate that configures Web API services.

Returns

Type
DevExpress.ExpressApp.WebApi.Services.XafWebApiBuilder

Remarks

The following code creates endpoints for the ApplicationUser and Contact business objects:

File: MySolution.WebApi\Startup.cs (MySolution.Blazor.Server\Startup.cs)

using MySolution.Module.BusinessObjects;
namespace MySolution.WebApi {
    public class Startup {
        public Startup(IConfiguration configuration) {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // ...
        public void ConfigureServices(IServiceCollection services) {
            // ...
            services.AddXafWebApi(Configuration, options => {
                options.BusinessObject<ApplicationUser>();
                options.BusinessObject<Contact>();
            })
            // in XPO applications, uncomment the following line
            // .AddXpoServices(); 
            // ...
        }
        // ...
    }
}
See Also