I'm exploring Blazor .NET 9 web apps, using rendermode set to auto (Server + Wasm). You can notice that a shared project is not created, but only Server and Client. In this context, the Layout
and Pages
folders also resides in the Client
project, and so far everything is ok.
In this context, I also tried to insert the following code
<p>@RendererInfo.Name</p>
on the Home
and I noticed how at the first start the render is executed on the Server. As soon as the download in the background on the Browser is finished, the render actually becomes WASM.
However, I was wondering why there is no SHARED project or if there is some technique or new method to ensure that data can be manipulated from the client. In other words, if you want to transfer information to a shared database, with this paradigm, you must always refer to the DataService
and the controller on the server to interact with it (and in this case it seems obvious to me to create a shared project to share the classes that represent the data layer) or have I missed something?
I'm exploring Blazor .NET 9 web apps, using rendermode set to auto (Server + Wasm). You can notice that a shared project is not created, but only Server and Client. In this context, the Layout
and Pages
folders also resides in the Client
project, and so far everything is ok.
In this context, I also tried to insert the following code
<p>@RendererInfo.Name</p>
on the Home
and I noticed how at the first start the render is executed on the Server. As soon as the download in the background on the Browser is finished, the render actually becomes WASM.
However, I was wondering why there is no SHARED project or if there is some technique or new method to ensure that data can be manipulated from the client. In other words, if you want to transfer information to a shared database, with this paradigm, you must always refer to the DataService
and the controller on the server to interact with it (and in this case it seems obvious to me to create a shared project to share the classes that represent the data layer) or have I missed something?
1 Answer
Reset to default 1There is no Shared project because the template does not contain an API that would benefit.
But it's very easy to fix, just add a Class library and reference it from the Client and from the API (which might be your Server, or not).
Note that for Components and UI logic you already have a common project: the Client is refenced from the Server.