Page/control lifecycle initialization¶
clsControllerBase.Initialize() is the central orchestration point invoked at the start of every request processed by a page or control derived from ViewPageBase/ViewControlBase. It runs the session-timeout check, both authorization gates, and the concrete model's pre-initialization hook, in a fixed order with no bypass paths.
| Field | Value |
|---|---|
| Operation ID | OP-MVC-001 |
| Trigger | ViewPageBase.Page_Init / ViewControlBase.Page_Init event, via the concrete clsFactoryBase.GetController() |
| Inputs | Current HttpContext (session, query string, request path) |
| Outputs | Populated Model, Session("navdata"), possible redirect/response termination |
| Primary components | clsControllerBase.Initialize |
| Entry point | SAIF.Presentation.Web.MVC\clsControllerBase.vb |
Steps¶
- Check
IsSessionTimedOut(IsPostBack And Session.IsNewSession) (BR-MVC-001). - If timed out: redirect to
"/" & ApplicationNamewith aMSGquery-string parameter identifying the timeout for internal clients (per the localIsInsideClientclassification, BR-MVC-008), or to/OnlineLogin/LoginScreen.aspx(clearing theSAIFAUTHcookie) for external/online clients, thenResponse.End(). - On failure: a
ThreadAbortExceptionraised byResponse.Redirectis swallowed viaThread.ResetAbort(). - If
__SAIFPIDis present on the query string, seedViewPage.ViewIDfrom it. - Call
SecurityCheck()(BR-MVC-003) — verifies aclsSecurityPrincipalexists onModel.Context, or challenges/denies the request. - If not authenticated and
clsEnvironment.InternalAddress(Request.UserHostAddress)(an externalSAIF.BOF.Frameworkdependency, distinct from the localIsInsideClientproperty behind BR-MVC-008) returnsTrue: issue an HTTP 401 withWWW-Authenticate: NTLM/Basicchallenge headers and end the response. - If not authenticated and
clsEnvironment.InternalAddressreturnsFalse: throwException("Not Authorized."). - If
Session("navdata")is empty, construct a newNavigationContext(Model.Context.UserID). - This delegates to
SAIF.Business.Menucollections (clsMenuAuthorizedItemCollection,clsApplicationCodeCollection,clsMenuCategoryCodeCollection) retrieved via an Oracle data layer (clsMSOracleDataLayer, constructed withEnvironmentConfigKeys.OracleDatabase).
Origin: Build a user's authorized menu (
SAIF.Business.Menu, OP-MENU-001) — the menu/authorization data retrieval logic itself (SQL/Criteria implementation) lives inSAIF.Business.Menu, outside this library's scope;NavigationContextonly supplies the Oracle connection context and consumes the resulting collections. Its applicable ordered logic: 1. AcceptIDataPortalInfoand the currentMenuUser(Model.Context.UserID), then choose the user-scoped SQL retrieval for authorized menu items. 2. Join the menu item, menu security, menu security user, menu page, application code, and menu category code tables so only matching user/item group intersections survive. 3. Add the public-item branch that returns rows with no menu security assignment (unsecured menu items are visible by default). 4. Union active favorites for the user-scoped query. 5. Materialize each row intoclsMenuAuthorizedItem, then expose filtered views such asFavorites,ApplicationItems,AppItemsByCategory, andSecuredAppItems— this is theclsMenuAuthorizedItemCollectionthatNavigationContext.IsMenuItem()queries in step 5 below. 5. CallRedirectUnauthorizedUsers()(BR-MVC-002) — callsNavigationContext.IsMenuItem(currentApp, currentItem). - If not authorized: clearSession("navdata")and redirect to/OnlineLogin/LoginScreen.aspx; log a warning trace. 6.Model.Pre_Init()— lazily runs the concrete model'sInitialize()override exactly once, and loadsclsPreferencesfor the current user/application via theSAIF.Presentationproject reference. 7.Load()— overridable hook invoked for the concrete controller; no default behavior in this library. 8. If the query string has keys, callHandleQuerystring(abstract/overridable hook) viaProcessQueryStrings(). 9. IfRequest.UrlReferreris present, callCheckContext(UrlReferrer.LocalPath). - This delegates to the Cross-application context hand-off operation.
Process flow¶
flowchart TD
Start([Page_Init]) --> Timeout{Session timed out?}
Timeout -->|Yes| Redirect1([Redirect + Response.End])
Timeout -->|No| SecCheck[SecurityCheck]
SecCheck --> Auth{Authenticated?}
Auth -->|No, clsEnvironment.InternalAddress true| Challenge([401 NTLM/Basic challenge])
Auth -->|No, clsEnvironment.InternalAddress false| Deny([Throw Not Authorized])
Auth -->|Yes| NavBuild{Session navdata present?}
NavBuild -->|No| BuildNav[Construct NavigationContext]
NavBuild -->|Yes| MenuCheck
BuildNav --> MenuCheck{IsMenuItem authorized?}
MenuCheck -->|No| Redirect2([Clear navdata, redirect to LoginScreen.aspx])
MenuCheck -->|Yes| PreInit[Model.Pre_Init]
PreInit --> Load[Load hook]
Load --> QS{Query string present?}
QS -->|Yes| HandleQS[HandleQuerystring]
QS -->|No| Referrer
HandleQS --> Referrer{UrlReferrer present?}
Referrer -->|Yes| CheckContext([CheckContext: hand-off])
Referrer -->|No| End([Initialization complete])
CheckContext --> End
Failure and edge-case behavior¶
- A
ThreadAbortExceptionfrom anyResponse.Redirect/Response.Endcall in this operation is caught and suppressed viaThread.ResetAbort(), so it never surfaces as an unhandled error. - If
SecurityCheck()throwsException("Not Authorized."), that exception propagates out ofInitialize()and is ultimately caught byViewPageBase.Page_Error→ Error handling. - No bypass path exists for any controller derived from
clsControllerBase— both authorization gates run unconditionally on every request.
Related documentation¶
Sources¶
- SAIF.Presentation.Web.MVC\clsControllerBase.vb
- SAIF.Presentation.Web.MVC\NavigationContext.vb