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¶
Enforce.ArgumentNotNullonhelperandmodel(BR-01).- Emit
<form id="frmWebContext">, addingstyle="display: none;"whenmodel.ShowContextBoxis false.WebContextViewModeldefaultsShowContextBoxtotrue(BR-46). - Emit hidden input
WebContextIdwithmodel.ContextId— the value OP-01 step 3 later reads back from the form. - Emit text input
WebContextValuewithmodel.ContextValueand classinput-sm form-control— the value OP-01 step 7 reads back. - Write the markup to
helper.ViewContext.Writer.
Process flow¶
The following diagram visualizes this operation's control flow.
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¶
Sources¶
src/Web.Mvc/Extensions/WebContextExtensions.cs