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
2 Answers
Reset to default 1Yes, 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:
- Execute command
dotnet new blazorwasm -n my-project
- Write code
- Execute command
dotnet publish --configuration RELEASE
- Open folder
bin/Release/net7.0/publish/wwwroot
- 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
版权声明:本文标题:Use Blazor for generating static serverless website (without .NET server) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741332192a2372829.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论