admin管理员组

文章数量:1287866

I want to create a website and I appreciate the framework Blazor. Usually Blazor is used in .NET with server-side .NET. I would like to build a website that I can host using Github Pages.

Therefore I would like to be able to compile the C# and Razor code in a bundle of web files: HTML, JS, WASM and CSS. I understand I'm limited to only client-side Blazor. Routing can be a nice feature, but a single page (and URL) is also an option.

Is this possible? How do I get started with my project? And how do I go from there?

I want to create a website and I appreciate the framework Blazor. Usually Blazor is used in .NET with server-side .NET. I would like to build a website that I can host using Github Pages.

Therefore I would like to be able to compile the C# and Razor code in a bundle of web files: HTML, JS, WASM and CSS. I understand I'm limited to only client-side Blazor. Routing can be a nice feature, but a single page (and URL) is also an option.

Is this possible? How do I get started with my project? And how do I go from there?

Share Improve this question edited Feb 25 at 7:25 Zhi Lv 21.7k1 gold badge27 silver badges37 bronze badges asked Feb 22 at 17:50 PizzaOverflowPizzaOverflow 1781 silver badge3 bronze badges 2
  • Do you want a static html site, or a server less WASM site? – MrC aka Shaun Curtis Commented Feb 22 at 19:37
  • Actually both could do. Now I've managed to do it using serverless WASM. But because the website will be mostly static, an optimalization could be to make it a static HTML site. – PizzaOverflow Commented Feb 23 at 10:02
Add a comment  | 

2 Answers 2

Reset to default 1

Yes, that is possible.

You start with a "Blazor WebAssembly standalone" project and then push it to a Github repository. Very easy with the "Git changes" tab in VS.

I think that you can only use the free Github Pages for a public repository.

Then you need to set up a pipeline (Github action), there are many walkthroughs available on the net.

I found out I didn't have a good understanding of BlazorWASM. The BlazorWASM template of the dotnet tool allows "publishing". This process results in an output with only web files (.HTML, .CSS, .JS, .WASM and browser .DLLs). I can run it in my browser without starting .NET.

This is the procedure I used:

  1. Execute command dotnet new blazorwasm -n my-project
  2. Write code
  3. Execute command dotnet publish --configuration RELEASE
  4. Open folder bin/Release/net7.0/publish/wwwroot
  5. Publish to GitHub by adding the contents to a git repo and push it to the GitHub remote repo.

本文标签: Use Blazor for generating static serverless website (without NET server)Stack Overflow