---
title: Register BOL services
summary: Registers the BOL services, API clients, and session support in the dependency injection container.
status: draft
owner: SAIF IT Core Services
last_reviewed: 2026-10-12
library: BolMiddleware
reference_type: package
operation_id: OP-01
trigger: Application startup calling RegisterBolServices
---

# Register BOL services

Consumers call `RegisterBolServices` once during service configuration so that every page model, view component, and facade in the library can be resolved. `BolRazorLayoutStartup` calls it automatically.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-01 |
| **Trigger** | Application startup calling `RegisterBolServices` |
| **Inputs** | `IServiceCollection` |
| **Outputs** | The same collection with BOL registrations added |
| **Primary components** | `BolServiceExtensions.RegisterBolServices` |
| **Entry point** | `src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs` |

## Steps

1. Add ASP.NET Core session services with `AddSession()`.
2. Register the four internal API client packages by chained calls: BOL Context, BOL Menu, Policy Header, and Policy Core clients.
3. Register `IHttpContextAccessor` as a singleton.
4. Register `ISecurityService` as scoped, and `IWebContextService`, `IMenuService`, and `IPolicyHeaderService` as singletons.
5. Register `IBolContextApiClient` as a singleton a second time; it repeats the registration made in step 2 and the last registration wins.
6. Register `IBolServicesContainer` and `ICookieService` as scoped and `IContextCookieHelper` as a singleton.
7. Return the collection for chaining.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([RegisterBolServices]) --> S1[AddSession]
	S1 --> S2[Register four API clients]
	S2 --> S3[Register accessor and facades]
	S3 --> S4[Register duplicate Context client]
	S4 --> S5["Register container, cookie service, helper"]
	S5 --> EndOk([Return IServiceCollection])
```

## Failure and edge-case behavior

- `UseSession()` and a distributed cache are not configured here; a consumer without them fails at runtime when session is first used, unless the base startup supplies them**.
- Singleton facades depend on API clients whose lifetimes are set inside the client packages; a lifetime capture risk is unknown**.
- The duplicate `IBolContextApiClient` registration is redundant and may hide a differently configured client from the client package.

> **Note:** Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Related documentation
- [Index](../index.md)
- [Overview](../overview.md)
- [Architecture](../architecture.md)
- [Dependencies](../dependencies.md)
- [Configuration](../configuration.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Security and authorization](../security-authorization.md)
- [Service registration](../service-registration.md)
- [API reference](../api/index.md)

## Sources
- src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs
- src/BolMiddleware/BolRazorLayoutStartup.cs
