Search code examples
blazorblazor-server-side

Blazor ver 8 - failing to load the resources


I am converting my Blazor server app version 6/7 to InteractiveServer version 8. To do this I basically copied _Host.cshtml to App.razor and then deleted _Host.cshtml.

So App.razor now has:

<head>
    <!-- Copyright (c) 2023 by David Thielen - ALL RIGHTS RESERVED -->
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="icon" type="image/png" href="favicon.png" />

    <base href="~/" />
    <!-- Bootstrap includes -->
    <link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />

    <!-- MudBlazor includes -->
    <link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />

    <!-- DevExpress includes -->
    <link href="_content/DevExpress.Blazor.RichEdit/dx-blazor-richedit.bs5.css"
          rel="stylesheet" asp-append-version="true" />
    <link href="_content/DevExpress.Blazor.Themes/blazing-berry.bs5.min.css"
          rel="stylesheet" asp-append-version="true" />

    <!-- AzureMapControl -->
    <link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" type="text/css" />

    <!-- app includes -->
    <link href="css/elements.css" rel="stylesheet" asp-append-version="true" />
    <link href="css/chrome.css" rel="stylesheet" asp-append-version="true" />
    <link href="css/components.css" rel="stylesheet" asp-append-version="true" />
    <link href="css/pages.css" rel="stylesheet" asp-append-version="true" />
    <link href="css/overrides.css" rel="stylesheet" asp-append-version="true" />
    <link href="LouisHowe.web.styles.css" rel="stylesheet" />

    <script src="~/js/Interop.js"></script>
    <HeadOutlet @rendermode="InteractiveServer" />
</head>

And none of the css filesa are loading. I'm getting a 404 failed to load resource on all of them. What do I need to do so these are found and loaded?


Solution

  • Found it - _Host.cshtml has:

    <base href="~/" />
    

    App.razor needs it to be:

    <base href="/" />
    

    I have no idea why this has changed. Somehow ~ has lost its meaning but I can't find anything that discusses this.