This document describes the client-side version checking and update notification system implemented for the Amendment application.
The system automatically checks for new versions of the application and notifies users when updates are available, providing a seamless way to keep the application up-to-date without manual intervention.
- Endpoint:
GET /api/version - Access: Anonymous (no authentication required)
- Purpose: Returns current server version information
- Response:
VersionResponseobject containing:Version: Assembly version (e.g., "1.0.0.0")BuildDate: When the application was builtBuildNumber: Build number from environment or assemblyEnvironment: Current environment name (Development, Production, etc.)
- Shared data model for version information
- Used by both client and server
- Interface:
IVersionCheckService - Purpose: Core service that manages version checking
- Features:
- Periodic version checking (every 5 minutes by default)
- Local storage of current version
- Version comparison logic
- Event-driven notifications when updates are available
- Purpose: UI component that displays update notifications
- Display Options:
- Snackbar notification (default)
- Modal dialog (optional)
- Features:
- User-friendly update prompt
- Version information display
- "Update Now" and "Later" options
- Automatic cache clearing and application reload
- Purpose: Lifecycle management component
- Responsibility: Starts and stops version checking service
- Integration: Added to MainLayout for application-wide coverage
- Purpose: Handles periodic checking and cache management
- Features:
setIntervalfor periodic checks- Service worker cache clearing
- Application reload functionality
- Debug utilities
The version check interval is configured in VersionCheckService.cs:
private const int CheckIntervalMinutes = 5;The version endpoint is configured as anonymous in HttpInterceptorService.cs:
private readonly List<string> _anonymousUrls = new ()
{
// ... other URLs
"/api/version"
};- Automatic Detection: System checks for updates every 5 minutes
- User Notification: When an update is detected:
- Snackbar appears with update information
- User can choose "Details" to see more info or "Update" to proceed
- Update Process: When user clicks "Update Now":
- Application cache is cleared
- Page is reloaded with the new version
- User's work is preserved (no data loss)
- Snackbar: Non-intrusive notification that appears at the bottom
- Modal: More prominent dialog (can be enabled via component parameters)
The system uses the following logic to determine if an update is available:
- Primary: Compare build dates (most reliable for deployments)
- Secondary: Compare version strings if build dates are identical
- Storage: Current version is stored in browser local storage
In Program.cs:
builder.Services.AddScoped<IVersionCheckService, VersionCheckService>();In MainLayout.razor:
<UpdateNotification ShowAsSnackbar="true" ShowAsModal="false"></UpdateNotification>
<VersionCheckManager></VersionCheckManager>- Version checks fail gracefully
- Errors are logged but don't interrupt user workflow
- Automatic retry on next scheduled check
- Service continues working even if individual checks fail
- Fallback mechanisms for cache clearing
- Debug utilities available in browser console
VersionControllerTests.cs: Tests for the version endpoint- Validates response format and anonymous access
- Version Detection: Deploy new version and verify notification appears
- Update Process: Click "Update Now" and verify reload works
- Cache Clearing: Verify old cached content is removed
Access debug utilities via:
window.amendmentVersionChecker.checkVersionNow()
window.amendmentVersionChecker.reloadApplication()
window.amendmentVersionChecker.clearServiceWorkerCache()- Client-side logs available in browser console
- Server-side logs in application logs
- Version check events are logged with appropriate levels
- Version endpoint is anonymous but only exposes non-sensitive build information
- No user data is transmitted during version checks
- Cache clearing is limited to application cache only
- Minimal: Checks occur every 5 minutes with small HTTP requests
- Efficient: Uses browser's built-in caching mechanisms
- Non-blocking: Version checks don't impact user interactions
Potential improvements for the system:
- Configurable check intervals
- Different notification styles based on update criticality
- Rollback capability
- Update scheduling (e.g., update during off-hours)
- Progressive web app update integration