Search code examples
blazor-webassembly

How to run Blazor Web Assembly locally


Is it possible to run a Blazor Webassembly app after publishing from the file system, invoking the index.htm in wwwroot? If I do this, the app doesn’t run. The console shows the following errors:

enter image description here

How can I fix this? Or is it not possible to execute the app in this way?

(For info, this is the .Net 6 Blazor Wasm template without any changes, just created and published the template.)


Solution

  • You can use any number of web servers to do that - this is my opinionated answer

    https://www.nuget.org/packages/dotnet-serve/#readme-body-tab

    Get started

    Install .NET 5 or newer and run this command:

    dotnet tool install --global dotnet-serve

    Start a simple server and open the browser by running

    dotnet serve -o

    ..and with HTTPS.

    dotnet serve -o -S