Skip to content

Initialize the web context service for a session

Set up the session-backed context dictionary and cached endpoint URL on first resolution in a session. Trigger: Autofac InstancePerRequest resolution of IWebContextService.

Field Value
Operation ID OP-15
Trigger Autofac InstancePerRequest resolution of IWebContextService
Inputs IEnvironmentService
Outputs Session-backed context dictionary and cached service URL
Primary components WebContextService constructor
Entry point src/Web/WebContextService.cs

Steps

  1. Read HttpContext.Current.Session.
  2. When Session["WebContextRepository"] is null, create a new Dictionary<string, IWebContext> there (BR-32).
  3. When Session["ContextServiceUrl"] is null, populate it from environmentService.GetConfigSetting(EnvironmentConfigKeys.WebContextServiceUrl) — the endpoint is resolved once per session, not per request (BR-33).
  4. Assign the session dictionary to items and the URL to serviceUrl.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([IWebContextService resolved])
    Session[Read HttpContext.Current.Session]
    Repo{WebContextRepository present?}
    InitRepo[Create session dictionary]
    Url{ContextServiceUrl present?}
    InitUrl[Resolve webContextServiceUrl setting]
    EndOk([Constructor complete])
    Start --> Session
    Session --> Repo
    Repo -->|No| InitRepo
    Repo -->|Yes| Url
    InitRepo --> Url
    Url -->|No| InitUrl
    Url -->|Yes| EndOk
    InitUrl --> EndOk

Failure and edge-case behavior

  • No unexpected failure paths beyond argument-guard exceptions and delegated dependency behavior were identified for this operation.

Sources

  • src/Web/WebContextService.cs