---
title: Load menu and context value
summary: Loads the menu and applies a submitted policy or claim number to the context.
status: draft
owner: SAIF IT Core Services
last_reviewed: 2026-10-12
library: BolMiddleware
reference_type: package
operation_id: OP-08
trigger: Handler execution on a BolMenuModel page
---

# Load menu and context value

Pages that derive from `BolMenuModel` display the BOL menu and the context textbox. Before the handler executes, this operation loads the menu for the current user and applies any submitted context value.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-08 |
| **Trigger** | Handler execution on a `BolMenuModel` page |
| **Inputs** | Session menu, current user id, submitted `ContextValue` |
| **Outputs** | `MenuData`, updated web context |
| **Primary components** | `BolMenuModel.OnPageHandlerExecuting`, `MenuService.GetMenu` |
| **Entry point** | `src/BolMiddleware/Models/BolMenuModel.cs` |

## Steps

1. Read the menu from the session; if it is absent, call `MenuService.GetMenu` with the current user id and save the result to the session ([BR-BOLMIDDLEWARE-007](../business-rules.md#br-bolmiddleware-007-menu-source-selection)).
   - If the BOL Menu API fails: the service returns null and `MenuData` stays the default empty menu.
2. If a `ContextValue` was submitted, classify it by length: fewer than seven or exactly nine characters is a policy number, otherwise a claim number ([BR-BOLMIDDLEWARE-008](../business-rules.md#br-bolmiddleware-008-context-value-classification)).
3. Store the number in the web context and refresh it for the handler.
4. The layouts render the context textbox as a visible input when `ChangeContextPrivilege` is true and as a hidden input otherwise ([BR-BOLMIDDLEWARE-019](../business-rules.md#br-bolmiddleware-019-context-textbox-visibility)). This is presentation only: step 2 reads the posted `contextvalue` without checking the flag.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Handler executing]) --> D1{Menu in session?}
	D1 -->|Yes| S1[Use session menu]
	D1 -->|No| S2[Call BOL Menu API and save to session]
	S1 --> D2{ContextValue submitted?}
	S2 --> D2
	D2 -->|No| EndOk([Handler runs])
	D2 -->|Yes| D3{Length under 7 or equal 9?}
	D3 -->|Yes| S3[Store as policy number]
	D3 -->|No| S4[Store as claim number]
	S3 --> EndOk
	S4 --> EndOk
```

## Failure and edge-case behavior

- A menu cached in the session is not refreshed until the session ends.
- The length test is the only validation; non-numeric values are accepted.
- The class carries `[IgnoreAntiforgeryToken]`, so posts to derived pages are not checked for anti-forgery tokens.

## 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/Models/BolMenuModel.cs
- src/BolMiddleware/Services/Menu/MenuService.cs
- src/BolMiddleware/Pages/Shared/_PolicyLayout.cshtml
