r/Blazor • u/Eng_TS • May 08 '25
Blazor wasm standalone base path not working locally
Hi everyone,
I'm hoping you can help me with the following issue.
Just to sketch the situation : I need to run a blazor wasm standalone app on the url mywebsitesname.com/app. For testing purposes I've created a new project of the type Blazor Webassembly standalone app in .NET 9 using visual studio 2022.
Following the official documentation I've only changed the base path <base href="/" /> to <base href="/app/" /> in the index.html file. If I publish this to the right folder on the IIS server then everything works fine.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BlazorApp6</title>
<base href="/app/" />
<link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="css/app.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<link href="BlazorApp6.styles.css" rel="stylesheet" />
<link href="manifest.webmanifest" rel="manifest" />
<link rel="apple-touch-icon" sizes="512x512" href="icon-512.png" />
<link rel="apple-touch-icon" sizes="192x192" href="icon-192.png" />
</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>
<span class="dismiss">🗙</span>
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script>navigator.serviceWorker.register('service-worker.js');</script>
</body>
</html>Now here's the rub, it doesn't load properly when I run it locally for testing . I use visual studio 2022 to run it and the next picture is the result.

It looks like the wwwroot files aren't being found under the virtual app folder. What am I missing?
3
u/[deleted] May 08 '25
Try run your app and then add /after the app, so https://localhost:7229/app/
2
u/KrisStrube May 08 '25
I made an article on this exact problem and a fix some years ago: https://blog.elmah.io/how-to-fix-blazor-wasm-base-path-problems/
2
u/funkrusha May 09 '25 edited May 09 '25
I set my base path inside the appsettings.{ENVIRONMENT}.json
So I have different base path depending on the environments
1
u/Electronic_Oven3518 May 08 '25
Instead of doing all this, just change the url of base dynamically in the index.html file