---
title: Get a web context by application and session
summary: Retrieve the context associated with a referring application and session, always from the remote service.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-09-17
library: SAIF.Framework.Web.Mvc
reference_type: package
operation_id: OP-05
trigger: OP-01 (resolve web context) step 5 (cross-application arrival)
---

# Get a web context by application and session

Retrieve the context associated with a referring application and session, always from the remote service. Trigger: OP-01 (resolve web context) step 5 (cross-application arrival).

| Field | Value |
| --- | --- |
| **Operation ID** | OP-05 |
| **Trigger** | OP-01 (resolve web context) step 5 (cross-application arrival) |
| **Inputs** | `applicationName`, `sessionId` |
| **Outputs** | `IWebContext` |
| **Primary components** | `WebContextService.Get(string applicationName, string sessionId)` |
| **Entry point** | `src/Web/WebContextService.cs` |

## Steps

1. `Enforce.ArgumentNotNullOrEmpty` on both `applicationName` and `sessionId` ([BR-01](../business-rules.md#br-01-guarded-arguments-reject-null-or-empty-input)).
2. Open a `WebContextServiceClient` at `serviceUrl` (`using` block).
3. Call `Channel.Get(applicationName, sessionId)` on the remote WCF service.**
4. `items.UpdateOrAdd(context.ContextId, context)` — cache in session ([BR-09](../business-rules.md#br-09-every-resolved-context-is-cached-by-id)).
5. Return the context. This path always contacts the remote service; it does not consult the session cache first.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Cross-application arrival])
	Guard[Guard applicationName/sessionId]
	Open[Open WebContextServiceClient]
	Call["Channel.Get app,session"]
	Cache[Cache in session]
	EndOk([Return context])
	Start --> Guard
	Guard --> Open
	Open --> Call
	Call --> Cache
	Cache --> EndOk
```

## Failure and edge-case behavior

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

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

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.


## Sources
- `src/Web/WebContextService.cs`
