With the release of .NET 8, Blazor Static SSR (Server Side Rendering) was introduced. Giving us finally the opportunity to migrate from Razor Pages to Blazor Static SSR.
While some things were more polished every possible way, we were getting other challenges. Cache busting was one of them. In Razor Pages, we could use the asp-append-version attribute to make sure that the browser would always request the latest version of the file.
But in Blazor, this attribute is not supported. So we had to find another way to make sure that the browser would always request the latest version of the file.
We went to reverse engineer the asp-append-version attribute on the LinkTagHelper.
Everything seems to point towards the FileVersionProvider in the Microsoft.AspNetCore.Mvc.ViewFeatures namespace for us to investigate.
So we injected it into our _Imports.razor file
We could now attempt to use it into our Razor components or rather Blazor components, given the confusing name.
We could now use it in our Blazor components.
Except this looks kind of dirty to do everywhere. So we created a component BlazorLink.razor that would do this for us.
Now just use it and just add attributes and parameters as required.
In your rendered HTML, it should render as follows:
If the resource was not found, it would throw an ArgumentException. This is useful for debugging purposes.