Blazor 8 wwwroot index.html

516 Views Asked by At

I'm playing with Blazor 8. When I publish the project, there is no index.html in the output:

enter image description here

It causes trouble when deploying on static web app, because it is expecting this file.

Thanks for the help!

I tried to add the index.html in the app, but it is not linked to the blazor app

1

There are 1 best solutions below

11
On

because it is expecting this file.

Yes, to run the Blazor Web Assembly App we need an index.html file which is in the wwwroot directory of the Application.

  • Razor pages will be loaded on top of the index.html file.

Check the below Workaround to deploy Blazor Web Assembly App to Azure Static Web Apps.

  • Created a Blazor Web Assembly App with .NET 8.0 Version.
  • Create a new Repository in GitHub.
  • The commands to push the code from Visual Studio to GitHub repro will be available when you create a new repo.
  git init
  git add README.md
  git commit -m "first commit"
  git branch -M main
  git remote add origin https://github.com/YourOrgName/RepoName.git
  git push -u origin main
  • In local, you can see .git folder with index.html page in it.

enter image description here

  • Cross the repo once after pushing the code. Make sure all the files and folders exists.

My GitHub Folder:

enter image description here

  • Create a new Static WebApp in Azure Portal.

Build Details:

Build Presets - Blazor
App Location - / 
Output Location - wwwroot
  • As my code files are in the root directory of GitHub,I have mentioned as /.
  • If you have code in any other folder you need to mention the folder name.

Deployment:

enter image description here

To confirm that my index.html is loading, I have added a bit of line as below in index.html file.

<P>Hello this is Index.html file</P>
  • Whenever I tried to run the app, I can see the Hello this is Index.html file line in all the navigations.

Output:

enter image description here