I have a project that has two pages and I need to create page one with blazor web assembly and create page two with blazor server side any idea on how to configure the project for this point?
- 1you cant run a mix of server & wasm together, it's due to happen for .net 7fuzzybear– fuzzybear2022-07-25 17:46:34 +00:00Commented Jul 25, 2022 at 17:46
- can I see any reference to show me that happens in .net 7?Regestea– Regestea2022-07-26 05:16:26 +00:00Commented Jul 26, 2022 at 5:16
- because one of the Microsoft engineers told me it is possibleRegestea– Regestea2022-07-26 05:18:25 +00:00Commented Jul 26, 2022 at 5:18
- 2youtu.be/3o91I6lD-Bo?t=3179 see that slide top right first item where it shows "Mix Blazor Server and WebAssembly" , however this is wish list of what we may or not get, I'm watching this space keenly, if you do find anything please postback..!fuzzybear– fuzzybear2022-07-26 15:23:38 +00:00Commented Jul 26, 2022 at 15:23
- 1I found this itnext.io/…Regestea– Regestea2022-07-26 16:09:48 +00:00Commented Jul 26, 2022 at 16:09
2 Answers
This future will be available in Blazor .net 8 for more information, visit .net 8 preview 5 features Learn More at Microsoft docs
Comments
The two hosting models cannot be mixed in one project at the time (in NET 6.0), as far as I know. However, there may be certain workarounds that provide what you need for your use case. Granted, I have little insights into your use case and why you would need a page from different hosting models, so these may not work for you.
Alternative 1:
You can use the third hosting model option, Blazor WASM Hosted, which is a Blazor WASM client served from an ASP.NET Core server project. With this, you can do everything you need on both client- and server-sides. This hosting model provides a lot of flexibility and advantages (e.g. prerendering). While it mainly uses HTTP to communicate between the two, you can use SignalR as well.
Alternative 2:
Alternatively, you could make two separate projects (one WASM and one Server) that you point to the same domain (with either a subdirectory for each, or different subdomains). It's more work to host this, and you may need to different build pipelines - still, it may work for your needs if the two pages are separate and independent.
Edit: This is coming to .NET 8 and Blazor United.