DeepWorks Studios Blazor Component Library

Demo user Administrator · Blazor Server Library 20261206222504-6e8ff32.dirty
This page needs an interactive render mode, so the static SSR demo does not list it. Open it in the interactive Server demo.

App update & maintenance

IDwsAppUpdateService merges the status document from any number of sources - a status file on the server, a polled URL, a SignalR hub, your API's responses, the page's service worker - and DwsUpdateBanner (in this demo's layout) shows it. The document has three independent parts: the release (which build is live), a plan (a restart or maintenance announced ahead - information only, it never reloads anything) and the maintenance state. What a page does with them depends on how it is hosted: a Blazor Server session is never asked to update to the build it already runs; it reloads by itself once the new version answers. A WebAssembly tab is offered a newer build, and must load it when the server no longer works with its build.

API Reference

Try it: the simulator

Each button publishes a document through a manual source that exists for your session only - nobody else sees it. Watch the banner at the top of the page. The buttons combine: a release stays when you then plan a restart, so you can see an update behind a plan notice (the About section below still offers it); Clear resets everything. Under Blazor Server a release only matters while a session runs on an older instance, so the release buttons show the 'newer version is live' offer; under WebAssembly they show the real update flow. In the offline-capable WebAssembly demo the simulation also plays the service worker: the build 'downloads' for a few seconds, then waits - but Update now asks the real worker, which has no new build, so it ends as a failed update.

Hosting model
Server
This page's build
20261206222504-6e8ff32.dirty
Phase
None
Connectivity
Online
Remaining
-
Possible
-
Show Code
AppUpdate.razor.cs

// Program.cs (both hosts): a manual source per session, added to the update service
builder.Services.AddScoped(_ => new DwsManualAppUpdateSource("Demo simulator"));
builder.Services.AddDWSAppUpdate(o => o.AddScopedSource<DwsManualAppUpdateSource>());

// AppUpdate.razor.cs
[Inject] private DwsManualAppUpdateSource Simulator { get; set; } = default!;

private void PlanRestart() => Simulator.Announce(new DwsAppUpdateDocument
{
    Plan = new DwsAppUpdatePlan
    {
        Type = DwsAppUpdatePlanType.Restart,
        Start = DateTimeOffset.UtcNow.AddMinutes(20),
        ExpectedMinutes = 5,
        Message = "The new grid is here.",
    },
});

private void SimulateOffline() => Simulator.Set(
    new DwsAppUpdateSourceReport(DwsAppUpdateDocument.Empty, DwsAppUpdateReachability.Unreachable));
MainLayout.razor

@* MainLayout.razor - once, above the page *@
<DwsUpdateBanner Name="MainLayout_UpdateBanner" />

Server side: the maintenance directory

The server package watches a directory for app-update.json (the status document) and maintenance.on (the flag a reverse proxy answers 503 for). The DWS Deployment Manager and maintenance-cli write both. The document is served at /_dws/app-update and pushed by the hub below it; every response carries Dws-App-Version (this instance's build) and Dws-App-Release (the live release). Once a Blazor Server page's session is gone, the browser asks for Dws-App-Version and reloads as soon as another build answers.

See the code tabs: Program.cs, the status document and the maintenance-cli commands.

Show Code
Program.cs

// Program.cs (Blazor Server) - package DWSBlazorComponentLibrary.AppUpdate.Server
builder.Services.AddDwsAppUpdateServer(o =>
{
    o.Directory = "/home/appuser/control";        // default: MAINTENANCE_DIRECTORY, MaintenanceMode:Directory
    o.MaintenancePathPrefixes.Add("/api");          // 503 while the service is in maintenance
});
builder.Services.AddDWSAppUpdate(o => o.AddSource<DwsFileAppUpdateSource>());

var app = builder.Build();
app.UseDwsAppUpdateHeaders();   // Dws-App-Version / Dws-App-Release / Dws-App-Min-Version on every response
app.MapDwsAppUpdate();          // GET /_dws/app-update, hub /_dws/app-update/hub
app-update.json

{
  "release": {                                  // written once the new version serves
    "current": "20261121143000-1a2b3c4",
    "minimumClient": "20261101090000-9f8e7d6",   // older WebAssembly tabs must update
    "notes": "The new grid is here."
  },
  "plan": {                                     // information only - never reloads anything
    "id": "deploy-20261121143000",
    "type": "Restart",                          // Restart | Maintenance | ClientUpdate
    "start": "2026-11-21T14:40:00Z",
    "expectedMinutes": 5
  },
  "maintenance": { "active": false }           // also set by maintenance.on
}
maintenance-cli

# done by the DWS Deployment Manager around a deployment: release, plan and maintenance
dws-deploy.sh maintenance status
# the maintenance flag: nginx answers 503, pages show maintenance (read-only)
maintenance-cli on --message "Database upgrade" --for 30
maintenance-cli off

WebAssembly: polling, SignalR and the service worker

A WebAssembly app polls the status document - a static app-update.json works with any static host - or receives it over SignalR with the AppUpdate.Client package. An offline-capable app adds AddServiceWorkerMonitoring: a newer release makes the service worker download the build, and 'Update now' is offered once it is downloaded - a reload before that would only bring back the old build.

The WebAssembly demo (on its own subdomain) uses the hub and the endpoint of this server; on the wasm-demo dev server it polls its app-update.json.

Show Code
Program.cs

// Program.cs (Blazor WebAssembly)
Uri baseAddress = new(builder.HostEnvironment.BaseAddress);
builder.Services.AddDWSAppUpdate(o => o
    // any static host: app-update.json next to index.html (404 = nothing known)
    .AddHttpPolling(new Uri(baseAddress, "app-update.json"), p => p.Interval = TimeSpan.FromMinutes(1))
    // or the server's endpoint and hub - package DWSBlazorComponentLibrary.AppUpdate.Client
    .AddSignalR(new Uri(apiBaseAddress, "_dws/app-update/hub"))
    // an offline-capable app (PWA): offer the update once the service worker has it
    .AddServiceWorkerMonitoring());

API responses & temporary offline mode

DwsAppUpdateHttpHandler in the HttpClient of your API learns from every response: the release headers tell a WebAssembly tab about a new release at once, a 503 switches to maintenance and a request without answer to offline - until the next answer. Your code reads State.IsReadOnly to keep work locally meanwhile.

The server side stamps the headers and answers 503 for the configured paths while the service is in maintenance: UseDwsAppUpdateHeaders().

Show Code
Program.cs

// Program.cs
builder.Services.AddDWSAppUpdate(o => o.AddApiResponseMonitoring());

// with IHttpClientFactory
builder.Services.AddHttpClient("api", c => c.BaseAddress = apiUri)
    .AddHttpMessageHandler<DwsAppUpdateHttpHandler>();
// without (Blazor WebAssembly's default)
builder.Services.AddScoped(sp => DwsAppUpdateHttpHandler.CreateHttpClient(sp, apiUri));

// in a component: keep work locally while the server is in maintenance or out of reach
[Inject] private IDwsAppUpdateService Updates { get; set; } = default!;

private async Task SaveAsync()
{
    if (Updates.State.IsReadOnly)
    {
        await DraftStore.KeepAsync(_model);   // your own local queue
        return;
    }

    await Api.PostAsJsonAsync("items", _model);
}

Saving before a required update

With ReloadAutomatically off, the banner leaves loading a required update to the app: OnStateChanged reports the Required phase with its countdown, the app saves a draft and then calls ApplyNowAsync.

This demo's layout keeps the automatic reload.

Show Code
MainLayout.razor

<DwsUpdateBanner Name="MainLayout_UpdateBanner" ReloadAutomatically="false" OnStateChanged="OnUpdateStateChanged" />
MainLayout.razor.cs

[Inject] private IDwsAppUpdateService Updates { get; set; } = default!;

private async Task OnUpdateStateChanged(DwsAppUpdateState state)
{
    if (state.Phase == DwsAppUpdatePhase.Required && state.Remaining == TimeSpan.Zero && !state.IsOffline)
    {
        await Drafts.SaveAllAsync();
        await Updates.ApplyNowAsync();
    }
}

The app's own offline notice

An app that polls its own API knows more than the browser: IsOffline reports its reachability (null leaves it to the banner), OfflineSince adds "Showing data from ..." (today: the time only), OfflineTitle and OfflineMessage replace the default texts (OfflineContent the whole details), OfflineColor Warning colours the strip orange, and OnRetry adds "Retry now", which reads "Retrying…" while the app checks. The same parameters exist for maintenance (MaintenanceTitle, MaintenanceMessage, MaintenanceContent), and an update notice still comes first. The banner below is a second one for this example; in an app it is the one in the layout.

Scanner API unreachabletoday 12:15 AM
Scanner API unreachableNew scans are paused; the results below are from the last successful sync.Showing data from today 12:15 AM.
Dashboard (cached data)
Show Code
MainLayout.razor
<DwsUpdateBanner Name="MainLayout_UpdateBanner" IsOffline="@_apiOffline" OfflineSince="@_lastSync"
                 OfflineColor="DwsColor.Warning" OfflineTitle="Scanner API unreachable"
                 OfflineMessage="New scans are paused; the results below are from the last successful sync."
                 OnRetry="RetryConnectionAsync" />
MainLayout.razor.cs
[Inject] private ApiStatus Status { get; set; } = default!;

private bool? _apiOffline;          // null until the first check: the banner's own detection
private DateTimeOffset? _lastSync;  // when the data on screen was loaded

private async Task RetryConnectionAsync()
{
    bool reachable = await Status.CheckAsync();
    _apiOffline = !reachable;
    if (reachable)
    {
        _lastSync = DateTimeOffset.Now;
    }
}

About page: DwsAppUpdateInfo

The same state as a page section for an About or settings page: the running and the latest version, the status, the connection, a scheduled restart or maintenance and the release notes - plus Update now, Check for updates and Reload without cache. A notice dismissed in the banner can still be read and acted on here.

App version and updates The app is up to date.
Running version
20261206222504-6e8ff32.dirty
Latest release
20261206222504-6e8ff32.dirty · 12/6/2026 11:57 PM
Connection
Online
What's new

Update button says what it does: Download, Install or Restart to update

Show Code

Interface-Description

Name Typ Default Description
State DwsAppUpdateState Idle IDwsAppUpdateService: what the user sees - Status, Phase, Connectivity, Deadline, Remaining, CanApplyNow, CanSnooze, CanDismiss, IsOffline, IsBlocking.
HostingModel DwsAppHostingModel? detected DwsAppUpdateOptions: Static, Server or WebAssembly rules; null = WebAssembly in the browser, else Server (set Static for an app that renders only statically).
DefaultRequiredCountdown TimeSpan 30 s DwsAppUpdateOptions: the countdown of a required update without a deadline.
SnoozeDuration TimeSpan 15 min DwsAppUpdateOptions: how long Later postpones a deferred update.
PlanFinalWindow TimeSpan 5 min DwsAppUpdateOptions: the last stretch before a plan starts; its notice can no longer be hidden.
OverlayLeadTime TimeSpan 10 s DwsAppUpdateOptions: how long before the deadline the blocking overlay shows.
WatchServerVersion bool true DwsAppUpdateOptions: Blazor Server - once the page's session is gone, the browser reloads as soon as another build answers the status endpoint.
CurrentVersion string? build id DwsAppUpdateOptions: the app's version, compared with announcements and the Dws-App-Version header.
Name Typ Parameters Description
StartAsync Task IDwsAppUpdateService: starts the sources and the browser connectivity watch; DwsUpdateBanner calls it after its first render.
RefreshAsync Task IDwsAppUpdateService: asks every source to look again now.
Snooze bool IDwsAppUpdateService: postpones a deferred update by SnoozeDuration (never into its final window).
Dismiss bool IDwsAppUpdateService: hides an optional update until a different one is announced.
ApplyNowAsync Task IDwsAppUpdateService: reloads the page for an app update.
ResetAppAsync Task IDwsAppUpdateService: after a failed update of an offline-capable app, removes its service worker and caches and reloads.
Name Typ Default Description
ShowConnectivity bool true DwsUpdateBanner: shows the offline / maintenance banner.
ShowOverlay bool true DwsUpdateBanner: shows the blocking overlay in the last seconds before an app update.
ReloadAutomatically bool true DwsUpdateBanner: reloads the page once an app update's deadline has passed and the server answers. Off: reload from OnStateChanged.
IsOffline bool? null DwsUpdateBanner: the app's own reachability (an app that polls its API). Null: the banner's detection. True / false: the app's state wins; a maintenance the service reports is shown either way.
OfflineSince DateTimeOffset? null DwsUpdateBanner: since when the app shows cached data - adds "Showing data from {time}" to the offline notice and the time to the strip (today: the time; otherwise date and time, in the localisation culture; WebAssembly in the browser's zone, elsewhere in the offset passed).
OfflineTitle / OfflineMessage string? null DwsUpdateBanner: replace the localised offline title and message. The live region reads the title and the app's message once per change of state.
OfflineContent RenderFragment? null DwsUpdateBanner: replaces the offline notice's details in the panel (message and "data from" line).
OfflineColor DwsColor DwsColor.Undefined DwsUpdateBanner: tone of the offline strip - Warning (orange), Error or Info; Undefined keeps the grey.
MaintenanceTitle / MaintenanceMessage string? null DwsUpdateBanner: replace the localised maintenance title and message.
MaintenanceContent RenderFragment? null DwsUpdateBanner: replaces the maintenance notice's details (message, expected return, operator note).
Name Typ Description
OnRetry EventCallback DwsUpdateBanner: when set, the offline and maintenance notices show "Retry now" (in the strip and the panel) and "Retrying…" while the app's task runs; the app checks its connection and updates IsOffline.
OnStateChanged EventCallback<DwsAppUpdateState> DwsUpdateBanner: every change of the update state, after the banner re-rendered.
StateChanged Action<DwsAppUpdateState> IDwsAppUpdateService: State changed - at most once a second while a countdown runs; may come from any thread.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The HTML ID attribute for the component.
AdditionalAttributes Dictionary<string, object> Additional HTML attributes for the component's root element.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.