---
title: Render the web context control
summary: Emit the hidden/visible web-context form used to round-trip context id and value.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-09-17
library: SAIF.Framework.Web.Mvc
reference_type: package
operation_id: OP-20
trigger: Razor view calling the helper
---

# Render the web context control

Emit the hidden/visible web-context form used to round-trip context id and value. Trigger: Razor view calling the helper.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-20 |
| **Trigger** | Razor view calling the helper |
| **Inputs** | `WebContextViewModel` |
| **Outputs** | `<form id="frmWebContext">` markup written to the view writer |
| **Primary components** | `WebContextExtensions.RenderWebContext(HtmlHelper, WebContextViewModel)` |
| **Entry point** | `src/Web.Mvc/Extensions/WebContextExtensions.cs` |

## Steps

1. `Enforce.ArgumentNotNull` on `helper` and `model` ([BR-01](../business-rules.md#br-01-guarded-arguments-reject-null-or-empty-input)).
2. Emit `<form id="frmWebContext">`, adding `style="display: none;"` when `model.ShowContextBox` is false. `WebContextViewModel` defaults `ShowContextBox` to `true` ([BR-46](../business-rules.md#br-46-web-context-control-hidden-unless-explicitly-enabled)).
3. Emit hidden input `WebContextId` with `model.ContextId` — the value [OP-01](op-01-resolve-web-context.md) step 3 later reads back from the form.
4. Emit text input `WebContextValue` with `model.ContextValue` and class `input-sm form-control` — the value [OP-01](op-01-resolve-web-context.md) step 7 reads back.
5. Write the markup to `helper.ViewContext.Writer`.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Razor view calls RenderWebContext])
	Guard[Guard helper/model]
	Form["Emit form, hidden if ShowContextBox false"]
	Hidden[Emit WebContextId hidden input]
	Text[Emit WebContextValue text input]
	Write[Write markup]
	EndOk([Markup emitted])
	Start --> Guard
	Guard --> Form
	Form --> Hidden
	Hidden --> Text
	Text --> Write
	Write --> 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/Extensions/WebContextExtensions.cs`
