Summary#
Two read-only strings that say what is running — for a footer, an "about" box, a support mail, or the shell's brand:
string AboutLine() => "Version " + App.Version + " · platform " + App.PlatformVersion;
[Route("/about")]
[AllowAnonymous]
component About() {
render { Text(AboutLine()); }
}Signature#
string App.Version // "1.0.8" — the app version answering; "dev" when the session serves no version
string App.PlatformVersion // "0.17.3" — the platform release serving it; "dev" for an unreleased buildDescription#
Which version is it?#
App.Version is the version whose model is answering the request. Deployed, that is the version the environment
serves: a production environment still on 1.0.7 while staging runs 1.0.8 reads 1.0.7 in production and 1.0.8
in staging, even though 1.0.8 is newer. On a local platform it is the version your last osy compile minted there —
that instance's own number, which is what is running on it.
App.PlatformVersion is the platform release serving the app — 0.17.3. A platform built from source rather than
released (a local platform, a trunk build) says dev, never a made-up number.
Server and browser agree#
Both are answered in-process on either side: a server function reads them from the session serving it, a page from
the values its boot data carries, which come from the same place. They need no [Server] call, no round trip and no
permission: a version is not a secret.
Show it in the shell#
Every shell built on AppChrome draws them when you ask: ShowVersion = true puts the app version after the
tagline and the platform release on a small line beneath it — factory · 1.0.8 over platform 0.17.3. Off by
default: the people running an app want it, its readers mostly do not. WorkbenchShell, whose brand is a bare
mark, puts the same two lines at the far end of its status line instead.
[Layout]
[AllowAnonymous]
component Shell() {
render {
SidebarShell(new AppChrome {
Product = "Lantern", Tagline = "workshop", ShowVersion = true, Home = "/",
Nav = [ new NavItem { Label = "Home", To = "/", Icon = Icons.Home } ],
}) { Outlet(); }
}
}
[Route("/")]
[AllowAnonymous]
component Home() {
render { Text("Welcome"); }
}Examples#
[Test]
void A_version_is_always_named() {
Assert.NotEqual("", App.Version);
Assert.NotEqual("", App.PlatformVersion);
Assert.Equal("Version " + App.Version + " · platform " + App.PlatformVersion, AboutLine());
}See also#
- App.BaseUrl — the address your app is known by, for links in mail and background work — the app's address:
App.BaseUrl,App.Domain,App.Slug - Environment — the app's own variables —
Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"): development or production - The standard library — and where each call runs — the rest of the standard library