---
title: NavigationContext
summary: API reference for NavigationContext.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.MVC
reference_type: package
---

# NavigationContext

`NavigationContext` is the per-user, per-session cache of authorized menu items that backs every menu-authorization decision in this library. It is constructed once per session by `clsControllerBase.Initialize` (cached in `Session("navdata")`), loading the user's authorized items from Oracle through `SAIF.Business.Menu`'s `clsMenuAuthorizedItemCollection`, and it is the type whose `IsMenuItem` method implements the library's only enforceable authorization decision — see [Load the user's authorized menu](../../operations/load-authorized-menu.md), [Enforce menu-based page authorization](../../operations/enforce-menu-authorization.md), and [Security and authorization](../../security-authorization.md). Its `ApplicationCodes` and `MenuCategories` reference data are cached at the application-domain level (`Static` locals), independent of any individual `NavigationContext` instance's lifetime.

## Purpose
- Loads and holds the authorized menu item set for a single user for the lifetime of their session ([BR-MVC-006](../../business-rules.md#br-mvc-006-the-authorized-menu-set-is-loaded-once-per-session)).
- Answers "may this user reach this application/page?" through `IsMenuItem`, the sole enforceable page-authorization check in this library ([BR-MVC-007](../../business-rules.md#br-mvc-007-page-access-requires-menu-authorization)).
- Resolves the currently executing page's menu metadata (`GetCurrentItem`, `GetCurrentPage`) from the live `HttpContext.Current.Request`, so screens can look up their own menu sequence/category without separately parsing the URL.
- Caches reference data (`ApplicationCodes`, `MenuCategories`) at the process level so repeated lookups do not re-query Oracle ([BR-MVC-018](../../business-rules.md#br-mvc-018-reference-data-caches-are-process-lifetime-not-per-session)).

## Context
- Namespace: `SAIF.Presentation.Web.MVC`*
- Assembly/package: `SAIF.Presentation.Web.MVC`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `New` | `Public Sub New(ByVal inUser As String)` | Builds a `clsMSOracleDataLayer` under DB user `MENU` using the `oracleDatabase` environment setting, then loads `MenuAuthorizedItems` for the upper-cased, trimmed user name; see [Load the user's authorized menu](../../operations/load-authorized-menu.md) |
| `MenuAuthorizedItems` | `Public Property MenuAuthorizedItems() As clsMenuAuthorizedItemCollection` | The current user's authorized menu item collection, loaded from `SAIF.Business.Menu` |
| `DumpDataToString` | `Public ReadOnly Property DumpDataToString() As String` | Diagnostic string combining the authorized-item count and a full dump of every menu item, for troubleshooting/tracing |
| `ApplicationCodes` | `Public ReadOnly Property ApplicationCodes() As clsApplicationCodeCollection` | The active application code reference collection, loaded from Oracle on first access process-wide and cached thereafter |
| `MenuCategories` | `Public ReadOnly Property MenuCategories() As clsMenuCategoryCodeCollection` | The menu category code reference collection, loaded from Oracle on first access process-wide and cached thereafter |
| `GetItemSeq` | `Public Function GetItemSeq(ByVal inApplication As String, ByVal inCategory As String, ByVal inPageLink As String) As Decimal` | Resolves the menu sequence number for a given application/category/page-link triple, or `0` if not found |
| `GetItem` | `Public Function GetItem(ByVal inCategory As String, ByVal inLink As String, Optional ByVal inAnyApp As Boolean = False) As clsMenuAuthorizedItem` | Looks up an authorized menu item by category and link, either within the current application or across all applications when `inAnyApp` is `True` |
| `GetCurrentItem` | `Public Function GetCurrentItem(ByVal inCategory As String) As clsMenuAuthorizedItem` | Looks up the authorized menu item matching the current request's application and raw URL, within the given category |
| `IsMenuItem` | `Public Function IsMenuItem(ByVal inApplication As String, ByVal inItem As String) As Boolean` | `True` when the given application/page pair exists in the user's authorized item set; the enforceable check behind [Enforce menu-based page authorization](../../operations/enforce-menu-authorization.md) ([BR-MVC-007](../../business-rules.md#br-mvc-007-page-access-requires-menu-authorization)) |
| `GetCurrentPage` | `Public Function GetCurrentPage() As clsMenuAuthorizedItem` | Resolves the authorized menu item for the exact application/page of the current request |

## Behavioral notes
- `ApplicationCodes` and `MenuCategories` are backed by `Static` local variables inside private `Shared` helper methods, so the first `NavigationContext` instance constructed in the application domain populates them for every subsequent instance and session — 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)).
- `GetItem`, `GetCurrentItem`, and `GetCurrentPage` all read `HttpContext.Current` directly rather than accepting the request context as a parameter, so they are only meaningful when called within an active web request.
- The query behind `MenuAuthorizedItems`, its underlying SQL text, and the Oracle menu schema itself are implemented in `SAIF.Business.Menu`, not in this library — this type only supplies the connection (`clsMSOracleDataLayer`) and the user identity.

## Constraints and usage notes
- The parameterless `Protected Friend Sub New()` exists but performs no initialization; the only meaningful constructor is `New(inUser As String)`, which requires a valid Oracle connection to succeed.
- Because `IsMenuItem` and related lookups depend on `ApplicationCodes`, an application whose code is missing or misconfigured in the `MENU` schema will never resolve to a non-empty `appCode`, causing every menu lookup for that application to fail closed.*

> **Note:** Statements marked with `*` were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.

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