---
title: Project web context onto the view model
summary: Copy the resolved web context onto the current view model after the action executes.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-09-17
library: SAIF.Framework.Web.Mvc
reference_type: package
operation_id: OP-02
trigger: MVC action-filter pipeline, after the action result is produced
---

# Project web context onto the view model

Copy the resolved web context onto the current view model after the action executes. Trigger: MVC action-filter pipeline, after the action result is produced.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-02 |
| **Trigger** | MVC action-filter pipeline, after the action result is produced |
| **Inputs** | `filterContext.Controller.ViewData.Model`, resolved `WebContext` |
| **Outputs** | `WebContextViewModelBase.WebContext.ContextId` / `.ContextValue` populated |
| **Primary components** | `WebContextControllerBase.OnActionExecuted(ActionExecutedContext)` |
| **Entry point** | `src/Web.Mvc/Controllers/WebContextControllerBase.cs` |

## Steps

1. Cast `ViewData.Model` to `WebContextViewModelBase`; a null cast result means the model does not participate in web context and the step is skipped ([BR-06](../business-rules.md#br-06-context-and-menu-decoration-require-the-matching-base-view-model)).
2. If both the model and `WebContext` are non-null, copy `WebContext.ContextId` into `model.WebContext.ContextId` and `WebContext.CurrentValue` into `model.WebContext.ContextValue`.
3. Call `base.OnActionExecuted(filterContext)`.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Action result produced])
	Cast[Cast ViewData.Model to WebContextViewModelBase]
	Chk{Model and WebContext non-null?}
	Copy[Copy ContextId/ContextValue]
	Skip([Skip decoration])
	EndOk([Continue])
	Start --> Cast
	Cast --> Chk
	Chk -->|Yes| Copy
	Chk -->|No| Skip
	Copy --> EndOk
	Skip --> 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)

## Sources
- `src/Web.Mvc/Controllers/WebContextControllerBase.cs`
