Skip to content

SAIF.Framework.Web.Mvc operations and processes

This page is the operation catalog and cross-operation hub for this library. Each operation's detailed, step-by-step logic lives in its own page under operations/.

Operation catalog

Operation Intent Trigger Inputs Outputs Rules
Resolve web context for an incoming request Resolve and populate the request's web context before the action runs MVC action-filter pipeline, before every action on a derived controller ActionExecutingContext (request form, query string, referrer, session), TempData WebContext protected property populated; Context= entry appended to the IIS log BR-01, BR-02, BR-03, BR-04, BR-05
Project web context onto the view model Copy the resolved web context onto the current view model after the action executes MVC action-filter pipeline, after the action result is produced filterContext.Controller.ViewData.Model, resolved WebContext WebContextViewModelBase.WebContext.ContextId / .ContextValue populated BR-06
Create a new web context Create a brand-new web context via the remote WCF service and cache it in session BR-04 cross-application arrival referenced by OP-01 step 6, or Get(contextId) on cache miss Optional context id; serviceUrl from session key ContextServiceUrl IWebContext; session cache updated BR-09
Get a web context by id (session-cache first) Return a cached web context by id, recreating it remotely on a cache miss OP-01 (resolve web context) step 4 contextId IWebContext BR-01, BR-10
Get a web context by application and session Retrieve the context associated with a referring application and session, always from the remote service OP-01 (resolve web context) step 5 (cross-application arrival) applicationName, sessionId IWebContext BR-01, BR-09
Save a web context remotely Persist a web context to the remote WCF service on cross-application navigation OP-07 (navigate between applications and views) step 3 (cross-application navigation) applicationName, sessionId, context Remote persistence; no return value BR-01
Navigate between applications and views Redirect the user to a target URL, handing off web context across or within applications POST from a view's navigation control NavigateViewModel.Url; Request.UrlReferrer; Session.SessionID; resolved WebContext RedirectResult to model.Url, or null when model.Url is null BR-01, BR-07, BR-08
Handle and log an unhandled action exception Log an unhandled action exception with full diagnostic context and redirect non-AJAX requests Any unhandled exception in an action on a controller the filter is applied to ExceptionContext (request, controller, exception) Log entry via ILogService; redirect for non-AJAX requests BR-11, BR-12, BR-13, BR-14
Authorize a request against SAIF roles Decide whether the current user is authorized for any of the roles declared on the filter MVC authorization filter stage on any controller/action decorated with SaifAuthorizeAttribute (applied as [SaifAuthorize]) HttpContextBase; Roles (comma-joined from the constructor); _ForceProductionRole; injected IUserProfileService and IEnvironmentService bool authorization decision BR-01, BR-15, BR-16, BR-17, BR-18
Handle an unauthorized request Log a denied authorization attempt and redirect the user to the error page AuthorizeCore returned false AuthorizationContext; injected ILogService and IEnvironmentService Logged SecurityException; RedirectResult to the error page BR-01, BR-15, BR-19, BR-20
Build and attach the Business Online menu Populate the current view model's menu, decorating it with the active item, category, and user status After every action on a controller derived from MenuControllerBase ViewData.Model, User.Identity.Name, request URL, HttpContext.Session["BusinessOnlineMenu"] MenuViewModelBase.Menu fully populated BR-01, BR-06, BR-21, BR-22, BR-23, BR-24, BR-25
Retrieve the Business Online menu for a user Query the Oracle-backed menu repository for a user's visible menu items and favorites OP-11 (build and attach the Business Online menu) step 3 (session cache miss) mailId, typically DOMAIN\user from User.Identity.Name BusinessOnlineMenu with Favorites and Items arrays BR-01, BR-26, BR-27, BR-28, BR-29, BR-30
Map the menu contract to view models Project the menu contract object onto MVC view models for rendering OP-11 (build and attach the Business Online menu) step 3 BusinessOnlineMenu MenuViewModel with Favorites and Items —
Register common web dependencies Wire MVC/Web API discovery, NHibernate unit-of-work factories, and menu/web-context/environment services into the consumer's Autofac container Consuming application startup composition* ContainerBuilder, a type from the application assembly, optional extra NHibernate class-map assemblies Registrations added to the container; the caller still owns Build() BR-01, BR-31
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 Autofac InstancePerRequest resolution of IWebContextService IEnvironmentService Session-backed context dictionary and cached service URL BR-32, BR-33
Project model-state errors into view models Translate ASP.NET model-state validation errors into JSON-friendly, grid-row-correlated view models Controller action returning validation results, typically as JSON ModelStateDictionary, optional grid property and row-id expressions ErrorViewModel[] BR-34, BR-35, BR-36
Collect user messages through ModelStateWrapper Record error, warning, and informational messages while de-duplicating repeated text Domain or service code writing messages through IMessageContainer Property name and message text Populated ModelStateDictionary, Warnings, Informationals BR-37, BR-38
Bind a JSON date value Bind a request value to a DateTime, tolerating missing or unparseable input MVC model binding for a bound DateTime when the binder is registered bindingContext.ValueProvider value for ModelName DateTime, or the raw null value BR-39, BR-40, BR-41
Render the Business Online menu Emit the favorites and category-grouped navigation menu markup for the current view Razor view calling the helper HtmlHelper, MenuViewModel, WebContextViewModel Markup written to helper.ViewContext.Writer; the "old school" variants return an HtmlString instead BR-01, BR-42, BR-43, BR-44, BR-45
Render the web context control Emit the hidden/visible web-context form used to round-trip context id and value Razor view calling the helper WebContextViewModel <form id="frmWebContext"> markup written to the view writer BR-01, BR-46
Render a linked (chained) dropdown Emit a <select> whose visible options are filtered client-side by a parent field's value Razor view calling the helper Field name or lambda expression, parent field id, IEnumerable<LinkedSelectListItem>, removeDefault, html attributes MvcHtmlString <select> markup BR-47, BR-48, BR-49, BR-50, BR-51
Render a character-counting textarea Emit a labeled textarea with client-side character-count data attributes Razor view calling the helper Field name or lambda, optional label text, html attributes, startLength (default 0), maxLength (default 4000) MvcHtmlString — label or span markup followed by the <textarea> BR-47, BR-52, BR-53
Build a toolbar through the fluent API Configure a server-rendered toolbar component through a fluent builder chain Razor view calling Html.SAIF().Toolbar() Fluent configuration lambda A configured Toolbar whose Render() and ToHtmlString() currently emit no markup BR-54
Determine Glimpse diagnostic access Decide whether the current request should be granted access to the Glimpse diagnostics panel Caller checking whether the Glimpse diagnostics panel should be shown* HttpContextBase — Server.MachineName and User bool BR-55, BR-56
Register style bundles Build and register the common and Kendo style bundles the consuming application serves Consuming application's bundle registration at startup* BundleCollection, virtual path, Kendo version string StyleBundle added to the collection and returned BR-57, BR-58, BR-59
Render a label with custom attributes Resolve and render a <label> element's text using a defined precedence order Razor view calling the helper Lambda expression, optional label text, html attributes MvcHtmlString BR-60, BR-61
Seed a default context value on cross-application arrival Set an initial context value when the user arrives from a different application Consuming application calling the helper after context resolution* Request referrer and URL, candidate values context.CurrentValue possibly set BR-62, BR-63
Clear grid pending-change collections Reset a grid's pending add/delete/update collections after a successful save while preserving displayed rows Controller resetting a grid after a successful save* GridViewModel<T> Added, Deleted, and Updated replaced with empty lists BR-64

Process flow diagram

The following diagram visualizes the primary operational flow across the core request-handling operations.

flowchart TD
    Req([Incoming request]) --> Ctx[OP-01 Resolve web context]
    Ctx --> Auth{SaifAuthorize applied?}
    Auth -->|Yes, denied| OP10[OP-10 Handle unauthorized request]
    Auth -->|Yes, allowed| Action[Controller action executes]
    Auth -->|Not applied| Action
    Action -->|Unhandled exception| OP08[OP-08 Handle and log exception]
    Action --> OP02[OP-02 Project context onto view model]
    OP02 --> OP11[OP-11 Build and attach menu]
    OP11 --> Render["Razor view renders menu, context, toolbar"]
    Render --> Resp([Response returned])
    OP10 --> Resp
    OP08 --> Resp

Failure and edge-case behavior

  • A null filterContext/model/service argument anywhere in this library throws immediately from Enforce rather than failing silently (BR-01).
  • Unhandled action exceptions are always routed through OP-08, which never itself throws even when logging fails.
  • Authorization denial is always routed through OP-10, which logs and redirects rather than returning an HTTP status code directly.
  • Menu and web-context decoration (OP-02, OP-11) silently no-op when the current view model does not derive from the expected base type.

Sources

  • src/Web.Mvc/ActionFilters/HandleExceptionAttribute.cs
  • src/Web.Mvc/ActionFilters/SaifAuthorizeAttribute.cs
  • src/Web.Mvc/Classes/Mappers.cs
  • src/Web.Mvc/Classes/MenuService.cs
  • src/Web.Mvc/Classes/ModelStateWrapper.cs
  • src/Web.Mvc/Controllers/MenuControllerBase.cs
  • src/Web.Mvc/Controllers/WebContextControllerBase.cs
  • src/Web.Mvc/Extensions/AutofacExtensions.cs
  • src/Web.Mvc/Extensions/BundleTableExtensions.cs
  • src/Web.Mvc/Extensions/LabelExtensions.cs
  • src/Web.Mvc/Extensions/MenuExtensions.cs
  • src/Web.Mvc/Extensions/ModelStateExtensions.cs
  • src/Web.Mvc/Extensions/WebContextExtensions.cs
  • src/Web.Mvc/ModelBinders/JsonDateTimeModelBinder.cs
  • src/Web.Mvc/UI/Extensions/HtmlHelperExtensions.cs
  • src/Web.Mvc/UI/Extensions/LinkedDropdownHelper.cs
  • src/Web.Mvc/UI/Extensions/TextCounterHelper.cs
  • src/Web.Mvc/UI/Toolbar/*.cs
  • src/Web.Mvc/UI/ViewComponentFactory.cs
  • src/Web.Mvc/ViewModels/GridRowViewModel.cs
  • src/Web/Extensions/HttpContextExtensions.cs
  • src/Web/WebContextService.cs
  • src/Web/WebContextServiceClient.cs