Skip to content

Page handler selection initialization

Every page that derives from BolContextModel runs this operation before its handler. It establishes the per-request context that the menu and policy header layers build on.

Field Value
Operation ID OP-03
Trigger Razor Pages handler selection on a BolContextModel page
Inputs HTTP request, BolContext cookie, session
Outputs Populated WebContext, contextCookie, RequestHelper, MyApplicationName
Primary components BolContextModel.OnPageHandlerSelected
Entry point src/BolMiddleware/Models/BolContextModel.cs

Steps

  1. Create a RequestHelper for the current HttpRequest.
  2. Read the application name from the root ApplicationName configuration value through GetRequiredValue; a missing value throws.
  3. Read the BolContext cookie into contextCookie when it exists (BR-BOLMIDDLEWARE-004).
  4. Later, in OnPageHandlerExecuting after model binding, resolve the web context as described in Resolve web context (BR-BOLMIDDLEWARE-001).
  5. Still in OnPageHandlerExecuting, for an external user run Capture external user information, which calls ISecurityClient.GetExternalUser (BR-BOLMIDDLEWARE-005, BR-BOLMIDDLEWARE-006).
  6. If the user is internal: skip the lookup.
  7. Make the WebContext available to the consumer handler.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Handler selected]) --> S1[Create RequestHelper]
    S1 --> S2[Read ApplicationName]
    S2 --> S3[Read BolContext cookie]
    S3 --> S3b([Handler executing])
    S3b --> S4[Resolve web context]
    S4 --> D{External user?}
    D -->|Yes| S5[Capture external user information]
    D -->|No| EndOk([Handler runs])
    S5 --> EndOk

Failure and edge-case behavior

  • A missing ApplicationName configuration value throws before the handler runs. The consumer sample places the value under AppSettings, which may not match the root key read here**.
  • ContextCookie deserialization trusts the unsigned cookie content; the cookie is not integrity protected.

Note: Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • src/BolMiddleware/Models/BolContextModel.cs
  • src/BolMiddleware/Services/Request/RequestHelper.cs