---
title: Load the user's authorized menu
summary: Loads and caches a per-user set of authorized menu items from Oracle, used for page-level authorization for the rest of the session.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.MVC
reference_type: package
operation_id: OP-MVC-06
trigger: First request of a session (step 5 of Initialize a request)
---

# Load the user's authorized menu

Constructs the `NavigationContext` that backs every subsequent menu-authorization check in the session. This is the only point in this library where Oracle is accessed, and it is delegated entirely to `SAIF.Business.Menu`.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-MVC-06 |
| **Trigger** | First request of a session (step 5 of [Initialize a request](initialize-request.md)) |
| **Inputs** | User ID (upper-cased, trimmed) |
| **Outputs** | `MenuAuthorizedItems` collection cached for the session |
| **Primary components** | `NavigationContext.New(inUser As String)` |
| **Entry point** | SAIF.Presentation.Web.MVC/NavigationContext.vb |

## Steps

1. Construct `clsMSOracleDataLayer` with DB user `MENU` and the connection string from `AppGlobal.EnvironmentService.GetConfigSetting(EnvironmentConfigKeys.OracleDatabase)` ([BR-MVC-015](../business-rules.md#br-mvc-015-menu-authorization-data-is-read-from-oracle-as-user-menu)).
2. Obtain `IDataPortalInfo` from the data layer.
3. Call `clsMenuAuthorizedItemCollection.GetMenuAuthorizedItems(dpi, user.Trim.ToUpper)` ([BR-MVC-015](../business-rules.md#br-mvc-015-menu-authorization-data-is-read-from-oracle-as-user-menu)).

> **Origin**: The authorized-item query itself — its SQL text and the Oracle menu tables it reads — is defined in `SAIF.Business.Menu`, not in this library. See that library's own operations and SQL documentation for the query implementation.
4. Application codes and menu categories are loaded lazily on first property access and held in `Static` locals shared across all instances for the lifetime of the application domain ([BR-MVC-018](../business-rules.md#br-mvc-018-reference-data-caches-are-process-lifetime-not-per-session)).
   - On first access within the process: a fresh load runs against Oracle.
   - On subsequent access: the cached `Static` value is returned without a database round trip.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([NavigationContext.New]) --> S1[Build clsMSOracleDataLayer as user MENU]
	S1 --> S2[Obtain IDataPortalInfo]
	S2 --> S3[GetMenuAuthorizedItems for user]
	S3 --> S4{ApplicationCodes / MenuCategories accessed?}
	S4 -->|First time| S5[Load from Oracle, cache in Static local]
	S4 -->|Already cached| S6[Return cached value]
	S5 --> EndOk([MenuAuthorizedItems cached in session])
	S6 --> EndOk
```

## Failure and edge-case behavior
- Because `ApplicationCodes`/`MenuCategories` are cached at the application-domain level, a reference-data change requires a process recycle to take effect ([BR-MVC-018](../business-rules.md#br-mvc-018-reference-data-caches-are-process-lifetime-not-per-session)).
- The per-session `MenuAuthorizedItems` set, by contrast, is loaded fresh for every new session, so a user's grants can change between sessions without a recycle ([BR-MVC-006](../business-rules.md#br-mvc-006-the-authorized-menu-set-is-loaded-once-per-session)).

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- SAIF.Presentation.Web.MVC/NavigationContext.vb
