---
title: WebContextService
summary: API reference for WebContextService.
status: draft
owner: SAIF IT Core Services
last_reviewed: 2026-10-12
library: BolMiddleware
reference_type: package
---

# WebContextService

Facade over `IBolContextApiClient` that wraps each call with logging and error handling, so a failure in the BOL Context API does not break the page.

## Purpose
- Call the BOL Context API to save, get, and create contexts, and log failures ([BR-BOLMIDDLEWARE-021](../../business-rules.md#br-bolmiddleware-021-silent-failure-degradation)).

## Context
- Namespace: `BolMiddleware.Services.Context`
- Assembly/package: `BolMiddleware`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| Constructor | `WebContextService(IBolContextApiClient client, ISaifLogService logService)` | Receives the API client and logger. |
| `SaveContext` | `bool SaveContext(ContextSaveRequest request)` | Saves through the API and returns false on failure. |
| `GetContext` | `ContextResult GetContext(string contextId)` | Loads by context id. |
| `GetContext` | `ContextResult GetContext(string sessionId, string applicationName)` | Loads by session and application. |
| `NewContext` | `ContextResult NewContext(string sessionId, string applicationName)` | Requests a new context. |

## Behavioral notes
- Exceptions are logged and not rethrown.

## Constraints and usage notes
- The client registration for `IBolContextApiClient` is duplicated; the last one wins.

## Sources
- src/BolMiddleware/Services/Context/WebContextService.cs
