Files
EnvelopeGenerator/EnvelopeGenerator.ReceiverUI/Services/AppVersionService.cs
TekH e319d4e833 Use versioned URLs for static assets
Updated `EnvelopeViewer.razor` to use versioned URLs for CSS and JS files via the new `AppVersionService`, enabling cache busting.

Introduced `AppVersionService` to generate versioned URLs based on the application version retrieved from assembly metadata.

Registered `AppVersionService` as a singleton in `Program.cs` for dependency injection.
2026-06-08 12:12:57 +02:00

27 lines
911 B
C#

namespace EnvelopeGenerator.ReceiverUI.Services;
/// <summary>
/// Provides application version for cache busting static assets.
/// Version is automatically incremented on each build via AssemblyVersion.
/// </summary>
public class AppVersionService
{
/// <summary>
/// Current application version (e.g., "1.0.0.0")
/// </summary>
public string Version { get; }
public AppVersionService()
{
// Get version from assembly metadata
Version = typeof(AppVersionService).Assembly.GetName().Version?.ToString() ?? "1.0.0.0";
}
/// <summary>
/// Generates versioned URL for static assets (cache busting)
/// </summary>
/// <param name="path">Asset path (e.g., "css/envelope-viewer.css")</param>
/// <returns>Versioned URL (e.g., "css/envelope-viewer.css?v=1.0.0.0")</returns>
public string GetVersionedUrl(string path) => $"{path}?v={Version}";
}