- Home
- /
- Documentation
- /
- Context options
Context options
Copy versioned AI context rules generated from module AIContextOptions files.
Configure PageInformation from the controller lifecycle
Rule for page metadata, alerts, body rendering, and request-scoped page state.
page-information-lifecycle
Use PageInformation and the PageBuilder controller lifecycle for page title, description, metadata, icons, scripts, stylesheets, schema data, alerts, body builder, and page container behavior.
Configure page-level information in the controller action before returning the view.
Do not scatter page metadata, scripts, stylesheets, or rendering decisions across unrelated helpers when PageInformation already owns the behavior.Protect public rendering contracts
Rule for changes that affect rendered HTML, fluent builders, Razor helpers, or page rendering order.
rendering-contract-stability
Treat DMBPageBuilder as infrastructure-level rendering code with cross-module impact.
Preserve public builder APIs, Razor helper behavior, rendered HTML shape, metadata order, asset order, and default rendering behavior unless a breaking change is explicitly requested.
Prefer additive extension points over replacing existing rendering contracts.Use typed HTML builders for semantic markup
Rule for fluent HTML tag builders, constrained builders, attributes, and raw HTML boundaries.
html-builder-semantics
Use existing DMBPageBuilder typed HTML builders and constrained builders for reusable markup instead of ad hoc raw HTML.
Keep tag name, attribute name, reserved attribute, style declaration, URL attribute, and raw content validation behavior deterministic.
Use raw HTML only when a typed builder or helper does not represent the required browser semantics.Register web assets through PageBuilder surfaces
Rule for JavaScript, CSS, link, icon, preload, and component-scoped asset registration.
web-asset-registration
Register shared or application-level JavaScript, CSS, and link assets through IWebAssetRegistry using RegisterGlobalScriptAsset, RegisterGlobalStylesheetAsset, or RegisterGlobalLinkAsset.
Register component-scoped assets on the current PageInformation with SetScriptFile or SetStylesheet only when the component renders.
Keep reusable browser-side behavior in static asset files such as wwwroot; do not generate reusable JavaScript or CSS from C# strings when a real asset can be registered.Let PageBuilder own local asset cache busting
Rule for local asset URLs, launch-token versioning, and external vendor URLs.
launch-token-cache-busting
Do not append manual cache-busting query strings such as ?v=... to local asset URLs.
PageBuilder applies ServerHelperConfiguration.Config.LaunchToken to local URLs during rendering when launch-token versioning is enabled.
External CDN URLs and intentionally versioned third-party URLs may keep explicit vendor versioning.Keep Razor helpers as rendering adapters
Rule for HtmlHelper extensions and PageBuilder-facing helper methods.
razor-helper-boundaries
Keep Razor helper extensions focused on exposing PageBuilder components, utilities, and rendering adapters to views.
Do not put business-flow logic, product-specific policy, Bootstrap-specific component behavior, or form-builder responsibilities into DMBPageBuilder helpers.
When helper behavior affects user-facing output, document the rendered contract and downstream impact.Use the central configuration lifecycle
Rule for package and host startup code that uses DMBServerHelper configuration primitives.
configuration-lifecycle
Use GenericConfiguration<T> and package-level configuration classes for DMB package startup.
Load ServerHelperConfiguration before package configuration that depends on server defaults, secrets, localization, URL composition, cookies, or sessions.
Keep configuration loading deterministic and document when new behavior runs: before file loading, during file loading, after file loading, or during application middleware registration.Use DMB package key nomenclature
Rule for appsettings keys, user secrets, and environment variable names.
configuration-keys
DMB package configuration keys must use the logical form DMB:{Package}:{Section}:{Name}.
Environment variables must replace each ':' with '__', for example DMB:Stripe:SecretKey becomes DMB__Stripe__SecretKey.
Keep secret keys and non-secret runtime settings in the same DMB:{Package}:... namespace when they belong to the same feature.
Do not introduce new package variables under implementation class names when a DMB:{Package}:... key exists or can be introduced.Register required secrets centrally
Rule for packages that declare, read, validate, or rotate secrets.
secret-management
Feature packages must register required secrets through ServerHelperConfiguration.Config.Secrets.Require(...).
Read secret values through the central SecretManager instead of custom IConfiguration lookups scattered through feature code.
Validate all registered secrets from one central host point after package configuration calls have completed.
Never log secret values; diagnostics may show missing keys and setup instructions only.
PreProduction and Production must fail closed when required secrets are missing.Treat cookie and session definitions as public contracts
Rule for changes that touch CookieDefinition, SessionDefinition, or typed helpers.
cookie-session-contracts
Cookie and session names, default values, groups, duration, security flags, serialization formats, and parsing behavior are externally observable.
Prefer additive changes and keep global cookie/session registries deterministic.
Review compatibility before changing existing definitions, deletion behavior, SameSite policy, Secure policy, or serialization formats.
Treat cookies, sessions, data protection, validation messages, and user-provided URL values as security-sensitive areas.Keep localization composition explicit
Rule for WebLocalizer and CombinedStringLocalizer usage.
localization-composition
Use WebLocalizer and CombinedStringLocalizer for shared localization lookup.
Keep localizer registration order, fallback behavior, and debug behavior explicit and deterministic.
Do not hide localization lookup-order changes behind generic wording; document downstream impact when lookup behavior changes.
Follow the local localization nomenclature before adding new keys.Use DMBServerHelper URL/domain helpers
Rule for code that composes host names, domains, or public URLs.
domain-url-composition
Use DMBServerHelper domain and URL composition helpers when host, domain, localhost, subdomain, or HTTPS URL behavior is involved.
Document accepted input formats, localhost handling, subdomain handling, and generated HTTPS URL format for domain APIs.
Treat user-controlled URL values as security-sensitive input and keep fallback behavior explicit.Use the central web configuration lifecycle
Rule for ASP.NET Core service registration and web application setup owned by DMBServerWebHelper.
web-configuration-lifecycle
Use ServerWebHelperConfiguration and WebGenericConfiguration<T> for shared ASP.NET Core web setup.
Keep reusable service registration, middleware setup, request localization, session guard behavior, embedded asset registration, captcha setup, and web utility configuration centralized in DMBServerWebHelper.
Do not move visual component, form builder, page layout, or application-specific website behavior into this package.Keep middleware order explicit
Rule for changes that affect ASP.NET Core middleware execution order.
middleware-order
Middleware registration is observable application behavior.
Document ordering assumptions when changing UseApp(...), session handling, request localization, exception handling, status code pages, static file registration, captcha endpoints, or cookie policy behavior.
Prefer additive extension points over replacing existing middleware order, and keep changes deterministic across host applications.Treat session and captcha behavior as security-sensitive
Rule for SessionGuardMiddleware, CaptchaFactory, CaptchaController, and session-backed validation flows.
session-captcha-contracts
Session and captcha behavior is security-sensitive and user-visible.
When changing SessionGuardMiddleware, CaptchaFactory, CaptchaController, or session-backed validation, document when session is loaded, which keys are used, how failures are handled, and what happens when session is unavailable.
Do not add new session dependencies without documenting key names, lifetime expectations, validation behavior, and compatibility impact.Preserve request localization contracts
Rule for request culture resolution, language utilities, and localization setup.
request-localization
Request culture resolution, accepted language parsing, localization setup, and language utility behavior affect user experience and routing assumptions.
Keep culture fallback behavior deterministic and document changes to request localization, Accept-Language parsing, LanguageTools, CountryWebTools, or localization resources.
Follow the local localization nomenclature before adding or renaming localization keys.Keep embedded static asset registration reusable
Rule for ServerWebHelperConfigureOptions and ASP.NET static file provider composition.
embedded-static-assets
Expose package-owned embedded wwwroot assets through reusable ASP.NET static file provider composition.
Do not replace embedded asset registration with host-specific physical paths unless explicitly requested.
When adding static file behavior, keep provider ordering deterministic and document how the host application receives or overrides the assets.Keep web utility helpers focused and deterministic
Rule for LanguageTools, CountryWebTools, ColorHelper, SecurityHashTools, and similar helper classes.
web-utility-boundaries
Keep utility helpers such as LanguageTools, CountryWebTools, CountryRegionInfoTools, ColorHelper, SecurityHashTools, and RequestCounter small, deterministic, and focused.
Do not turn utility classes into application policy engines or service containers.
Treat hashing, user-provided values, locale data, and request-derived values as security-sensitive inputs and document accepted formats and fallback behavior.