There is a quite easy solution to this if you are using ASP.NET Core hosted Blazor WASM:
Create a new empty Razor Page in your Server project for Blazor WASM. Call it BlazorIndex
or something else you like.
It will look something like this:
@page
@model BlazorAppIndividualAccounts.Server.Pages.BlazorIndexModel
@{
}
Now add @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Like this:
@page
@model BlazorAppIndividualAccounts.Server.Pages.BlazorIndexModel
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
}
Then edit Program.cs
and replace app.MapFallbackToFile("index.html");
with app.MapFallbackToPage("/BlazorIndex");
Now copy your values from Client wwwroot index.html
to BlazorIndex.cshtml
. Then remove index.html
from Client wwwroot.
Complete example with asp-append-version="true"
for css/app.css
and AuthenticationService.js
:
@page
@model BlazorAppIndividualAccounts.Server.Pages.BlazorIndexModel
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>BlazorAppIndividualAccounts</title>
<base href="/" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/app.css" rel="stylesheet" asp-append-version="true" />
<link rel="icon" type="image/png" href="favicon.png" />
<link href="BlazorAppIndividualAccounts.Client.styles.css" rel="stylesheet" />
</head>
<body>
<div id="app">
<svg class="loading-progress">
<circle r="40%" cx="50%" cy="50%" />
<circle r="40%" cx="50%" cy="50%" />
</svg>
<div class="loading-progress-text"></div>
</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss"></a>
</div>
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js" asp-append-version="true"></script>
<script src="_framework/blazor.webassembly.js"></script>
</body>
</html>
Now you will append a hash to the URL of static files and you can also use any other feature from Razor Pages that you like.
