---
title: BolMiddleware service registration
summary: Dependency injection registrations and startup base classes provided by BolMiddleware.
status: draft
owner: SAIF IT Core Services
last_reviewed: 2026-10-12
library: BolMiddleware
reference_type: package
---

# BolMiddleware service registration

BolMiddleware exposes one registration extension, `RegisterBolServices`, and one startup base class, `BolRazorLayoutStartup`, that calls it. The library registers no hosted services and no feature flags.

## Registration extension catalog
| Extension | Namespace | Target | Registers | Source |
| --- | --- | --- | --- | --- |
| `RegisterBolServices` | `BolMiddleware` | `IServiceCollection` | Session support, four API clients, the security, context, menu, and policy header facades, the services container, the cookie service, and the context cookie helper. | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |

## Service registration catalog
| Service | Implementation | Lifetime | Registered by | Source |
| --- | --- | --- | --- | --- |
| ASP.NET Core session services | `AddSession()` | Framework default | `RegisterBolServices` | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| BOL Context, BOL Menu, Policy Header, and Policy Core API clients | Client package registration extensions | Set inside each client package** | `RegisterBolServices` | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| `IHttpContextAccessor` | `HttpContextAccessor` | Singleton | `RegisterBolServices` | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| `ISecurityService` | `SecurityService` | Scoped | `RegisterBolServices` | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| `IWebContextService` | `WebContextService` | Singleton | `RegisterBolServices` | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| `IMenuService` | `MenuService` | Singleton | `RegisterBolServices` | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| `IPolicyHeaderService` | `PolicyHeaderService` | Singleton | `RegisterBolServices` | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| `IBolContextApiClient` | `BolContextApiClient` | Singleton | `RegisterBolServices` as a second registration after the client package registered it; the last registration wins | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| `IBolServicesContainer` | `BolServicesContainer` | Scoped | `RegisterBolServices` | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| `ICookieService` | `CookieService` | Scoped | `RegisterBolServices` | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| `IContextCookieHelper` | `ContextCookieHelperService` | Singleton | `RegisterBolServices` | src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs |
| `IAppMap` | `BasicAppMap` (unbound default instance) | Scoped | `BolRazorLayoutStartup.ConfigureServices` | src/BolMiddleware/BolRazorLayoutStartup.cs |

## Options configuration
| Options type | Configuration section | Registered by | Source |
| --- | --- | --- | --- |
| `BasicAppMap` | `BasicAppMap` | `BolRazorLayoutStartup.ConfigureServices` | src/BolMiddleware/BolRazorLayoutStartup.cs |

Views read the bound `IOptions<BasicAppMap>`; `IAppMap` resolves a separate default instance and therefore does not reflect the configuration.

## Startup base classes
| Class | Base | Behavior | Source |
| --- | --- | --- | --- |
| `BolRazorLayoutStartup` | `OidcRazorStartup` | Sets `EnableLegacyBolAuthMiddleware` to true, calls the base `ConfigureServices`, calls `RegisterBolServices`, binds `BasicAppMap`, and registers `IAppMap`. `Configure` is not overridden, so the inherited `AppStartup.Configure` order applies (buffering, optional session, authentication, HSTS, optional HTTPS redirect, static files, routing, authorization, UI and logger setup), and `EnableLegacyBolAuthMiddleware` affects only DI registration of `LegacyBolAuthMiddleware`, not the pipeline.* | src/BolMiddleware/BolRazorLayoutStartup.cs |

`BolLayoutStartup` in `src/BolMiddleware/BolLayoutStartup.cs` is entirely commented out and registers nothing.

## Middleware pipeline
The library adds no middleware of its own. The base class flag `EnableLegacyBolAuthMiddleware` only registers `LegacyBolAuthMiddleware` in dependency injection; the inherited `AppStartup.Configure` does not add it to the pipeline.* `UseSession()` is not called here; the inherited `Configure` adds session only when the base startup's session option is enabled.*

## Required-but-not-registered services
| Service | Used by | Expected provider |
| --- | --- | --- |
| `IEnvironmentClient` | `BolServicesContainer`, `BolContextModel` | Platform base startup* |
| `ISaifLogService` | Facades and the services container | Platform base startup* |
| `ISecurityClient` | `SecurityService` | `SAIF.NetCore.AuthService`, via the platform base startup* |
| `IConfiguration`, `IWebHostEnvironment` | Page models and views | ASP.NET Core host |
| Distributed cache for session | Session middleware | Consuming application** |

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. 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)
- [API reference](api/index.md)

## Sources
- src/BolMiddleware/Extensions/BolMiddlewareExtensions.cs
- src/BolMiddleware/BolRazorLayoutStartup.cs
- src/BolMiddleware/BolLayoutStartup.cs
- src/BolMiddleware/Services/BolServicesContainer.cs
