You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For several months I have been trying to understand some internals of Blazor. In particular the interaction and use of wasm and the server.
My goal is simple (I think):
Use a WebAssembly dedicated to the dynamic rendering of my components depending on the context. (User / profile).
I spent hours and hours on Microsoft Learning and collected I don't know how many badges and trophies!
I started searching the web and GitHub to find the best practice(s) to solve my problems, without success.
I started with the models offered in Visual Studio, I tested the 2 concerning Blazor: Blazor Web Application and Blazor WebAssembly Application. I looked at the differences and the common points to understand them better!?
Since then I have switched (as best I could) to Blazor Fluent, which seemed like a very good idea to me. Because I was starting to write too many C#/JavaScript components to make everything more fun.
As I am an adventurer I also switched to .Net 9!
If I create a standalone WebAssembly application everything works. This allowed me to test my custom components. As well as several Helpers and Tools.
But I absolutely want to start with a web page on the server (for practical reasons to understand). Let's say Web Blazor Hybrid like MAUI Blazor Hybrid.
This web page will initialize all the mechanics embedded in my WebAssembly.
The contents (retrieved from the server, Json or other) will be generated dynamically via this dll.
User interactions will also be managed by this dll and then redirected to the server if necessary.
But when I try to switch back to client server mode!? It's catastrophic.
I tried to mix the RenderMode in all directions without the expected result.
And many things no longer work or half-work! As a result, I'm lost!
So I would like to find a solution or guidelines for my project.
The principle is simple:
I have a Web application (the server) and my WebAssembly (the client).
I had started to put the MainLayout on the client side, bad choice!
So I put it back on the server side, light version which loads my custom layout component on the client side.
I create all my components on the client side: Header, NavMenu, Footer and Sidebar... via this client layout component. All this is displayed well.
In the same spirit, I started to put my 2 poor test pages on the client side. They were not displayed and once out of 2 a 404 error!?
So I put the home page back on the server side and it still does not display!?
I forgot, I use APIs (and Azure functions pending) to retrieve the content(s) dynamically.
Of course I use the only method that allows to dynamically create components: BuildRenderTree().
A method that has been criticized quite a bit on GitHub??? I don't understand why, of course the development is sometimes complex but the result is there.
I come back to my question: What are the best practices for:
From a WebAssembly to be able to dynamically load all my components.
And to correctly manage user interactions by going back to via the server if necessary.
What is the structure of the Server and Client projects.
What are the files that are really necessary on each side.
There is a blur between the files used on the server side and on the client side depending on whether you look at the Blazor Web Application or Blazor Application documentation.
I have several files, which are they used or not?
A program.cs on the server side
A program.cs on the client side? Mandatory otherwise a compilation error but apparently I never called it?
A startup.cs, on the server side that I removed?
An Index.html, client side that I also removed?
An App.rasor server side.
An App.rasor client side that I removed?
An _Import.razor on both sides that look strangely similar.
...
My recent problem, while waiting for the others, is the following:
My custom NavMenu component (a FluentNavMenu) client side is finally displayed, thanks Fluent UI.
But the Hrefs are inactive (or lost) and if they are active the pages (via Blazor routing?) are not displayed or else error 404?!
Likewise the clicks of my menu bar (in the header) no longer work (to be checked, since my switch to Fluent UI).
Should I leave the Blazor mechanics aside?
And redo JavaScript to ask my server to dynamically deliver the content of my pages and components.
Knowing that a page is a component!
I have another question about the @Body mechanics.
Where is the source code on GitHub? As well as the Href routing mechanics --(magic?)-> Render Body?
Of course I love magic but I like to understand the internals to debug for example.
Right now it's mission impossible to follow the JavaScript, it's unreadable.
There you go, I think I've been clear enough.
Thanks in advance,
Best regards,
Pascal
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello everyone,
For several months I have been trying to understand some internals of Blazor. In particular the interaction and use of wasm and the server.
My goal is simple (I think):
Use a WebAssembly dedicated to the dynamic rendering of my components depending on the context. (User / profile).
I spent hours and hours on Microsoft Learning and collected I don't know how many badges and trophies!
I started searching the web and GitHub to find the best practice(s) to solve my problems, without success.
I started with the models offered in Visual Studio, I tested the 2 concerning Blazor: Blazor Web Application and Blazor WebAssembly Application. I looked at the differences and the common points to understand them better!?
Since then I have switched (as best I could) to Blazor Fluent, which seemed like a very good idea to me. Because I was starting to write too many C#/JavaScript components to make everything more fun.
As I am an adventurer I also switched to .Net 9!
If I create a standalone WebAssembly application everything works. This allowed me to test my custom components. As well as several Helpers and Tools.
But I absolutely want to start with a web page on the server (for practical reasons to understand). Let's say Web Blazor Hybrid like MAUI Blazor Hybrid.
This web page will initialize all the mechanics embedded in my WebAssembly.
The contents (retrieved from the server, Json or other) will be generated dynamically via this dll.
User interactions will also be managed by this dll and then redirected to the server if necessary.
But when I try to switch back to client server mode!? It's catastrophic.
I tried to mix the RenderMode in all directions without the expected result.
And many things no longer work or half-work! As a result, I'm lost!
So I would like to find a solution or guidelines for my project.
The principle is simple:
I have a Web application (the server) and my WebAssembly (the client).
I had started to put the MainLayout on the client side, bad choice!
So I put it back on the server side, light version which loads my custom layout component on the client side.
I create all my components on the client side: Header, NavMenu, Footer and Sidebar... via this client layout component. All this is displayed well.
In the same spirit, I started to put my 2 poor test pages on the client side. They were not displayed and once out of 2 a 404 error!?
So I put the home page back on the server side and it still does not display!?
I forgot, I use APIs (and Azure functions pending) to retrieve the content(s) dynamically.
Of course I use the only method that allows to dynamically create components: BuildRenderTree().
A method that has been criticized quite a bit on GitHub??? I don't understand why, of course the development is sometimes complex but the result is there.
I come back to my question: What are the best practices for:
From a WebAssembly to be able to dynamically load all my components.
And to correctly manage user interactions by going back to via the server if necessary.
What is the structure of the Server and Client projects.
What are the files that are really necessary on each side.
There is a blur between the files used on the server side and on the client side depending on whether you look at the Blazor Web Application or Blazor Application documentation.
I have several files, which are they used or not?
...
My recent problem, while waiting for the others, is the following:
My custom NavMenu component (a FluentNavMenu) client side is finally displayed, thanks Fluent UI.
But the Hrefs are inactive (or lost) and if they are active the pages (via Blazor routing?) are not displayed or else error 404?!
Likewise the clicks of my menu bar (in the header) no longer work (to be checked, since my switch to Fluent UI).
Should I leave the Blazor mechanics aside?
And redo JavaScript to ask my server to dynamically deliver the content of my pages and components.
Knowing that a page is a component!
I have another question about the @Body mechanics.
Where is the source code on GitHub? As well as the Href routing mechanics --(magic?)-> Render Body?
Of course I love magic but I like to understand the internals to debug for example.
Right now it's mission impossible to follow the JavaScript, it's unreadable.
There you go, I think I've been clear enough.
Thanks in advance,
Best regards,
Pascal
Beta Was this translation helpful? Give feedback.
All reactions